documentation.d.ts 3.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209
  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. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * 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.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * 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).
  162. * 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.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @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.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module BABYLON {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module BABYLON {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module BABYLON {
  409. /**
  410. * Interface used to define the mechanism to get data from the network
  411. */
  412. export interface IWebRequest {
  413. /**
  414. * Returns client's response url
  415. */
  416. responseURL: string;
  417. /**
  418. * Returns client's status
  419. */
  420. status: number;
  421. /**
  422. * Returns client's status as a text
  423. */
  424. statusText: string;
  425. }
  426. }
  427. declare module BABYLON {
  428. /**
  429. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  430. */
  431. export class WebRequest implements IWebRequest {
  432. private _xhr;
  433. /**
  434. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  435. * i.e. when loading files, where the server/service expects an Authorization header
  436. */
  437. static CustomRequestHeaders: {
  438. [key: string]: string;
  439. };
  440. /**
  441. * Add callback functions in this array to update all the requests before they get sent to the network
  442. */
  443. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  444. private _injectCustomRequestHeaders;
  445. /**
  446. * Gets or sets a function to be called when loading progress changes
  447. */
  448. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  449. /**
  450. * Returns client's state
  451. */
  452. readonly readyState: number;
  453. /**
  454. * Returns client's status
  455. */
  456. readonly status: number;
  457. /**
  458. * Returns client's status as a text
  459. */
  460. readonly statusText: string;
  461. /**
  462. * Returns client's response
  463. */
  464. readonly response: any;
  465. /**
  466. * Returns client's response url
  467. */
  468. readonly responseURL: string;
  469. /**
  470. * Returns client's response as text
  471. */
  472. readonly responseText: string;
  473. /**
  474. * Gets or sets the expected response type
  475. */
  476. responseType: XMLHttpRequestResponseType;
  477. /** @hidden */
  478. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  479. /** @hidden */
  480. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  481. /**
  482. * Cancels any network activity
  483. */
  484. abort(): void;
  485. /**
  486. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  487. * @param body defines an optional request body
  488. */
  489. send(body?: Document | BodyInit | null): void;
  490. /**
  491. * Sets the request method, request URL
  492. * @param method defines the method to use (GET, POST, etc..)
  493. * @param url defines the url to connect with
  494. */
  495. open(method: string, url: string): void;
  496. }
  497. }
  498. declare module BABYLON {
  499. /**
  500. * File request interface
  501. */
  502. export interface IFileRequest {
  503. /**
  504. * Raised when the request is complete (success or error).
  505. */
  506. onCompleteObservable: Observable<IFileRequest>;
  507. /**
  508. * Aborts the request for a file.
  509. */
  510. abort: () => void;
  511. }
  512. }
  513. declare module BABYLON {
  514. /**
  515. * Scalar computation library
  516. */
  517. export class Scalar {
  518. /**
  519. * Two pi constants convenient for computation.
  520. */
  521. static TwoPi: number;
  522. /**
  523. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  524. * @param a number
  525. * @param b number
  526. * @param epsilon (default = 1.401298E-45)
  527. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  528. */
  529. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  530. /**
  531. * Returns a string : the upper case translation of the number i to hexadecimal.
  532. * @param i number
  533. * @returns the upper case translation of the number i to hexadecimal.
  534. */
  535. static ToHex(i: number): string;
  536. /**
  537. * Returns -1 if value is negative and +1 is value is positive.
  538. * @param value the value
  539. * @returns the value itself if it's equal to zero.
  540. */
  541. static Sign(value: number): number;
  542. /**
  543. * Returns the value itself if it's between min and max.
  544. * Returns min if the value is lower than min.
  545. * Returns max if the value is greater than max.
  546. * @param value the value to clmap
  547. * @param min the min value to clamp to (default: 0)
  548. * @param max the max value to clamp to (default: 1)
  549. * @returns the clamped value
  550. */
  551. static Clamp(value: number, min?: number, max?: number): number;
  552. /**
  553. * the log2 of value.
  554. * @param value the value to compute log2 of
  555. * @returns the log2 of value.
  556. */
  557. static Log2(value: number): number;
  558. /**
  559. * Loops the value, so that it is never larger than length and never smaller than 0.
  560. *
  561. * This is similar to the modulo operator but it works with floating point numbers.
  562. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  563. * With t = 5 and length = 2.5, the result would be 0.0.
  564. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  565. * @param value the value
  566. * @param length the length
  567. * @returns the looped value
  568. */
  569. static Repeat(value: number, length: number): number;
  570. /**
  571. * Normalize the value between 0.0 and 1.0 using min and max values
  572. * @param value value to normalize
  573. * @param min max to normalize between
  574. * @param max min to normalize between
  575. * @returns the normalized value
  576. */
  577. static Normalize(value: number, min: number, max: number): number;
  578. /**
  579. * Denormalize the value from 0.0 and 1.0 using min and max values
  580. * @param normalized value to denormalize
  581. * @param min max to denormalize between
  582. * @param max min to denormalize between
  583. * @returns the denormalized value
  584. */
  585. static Denormalize(normalized: number, min: number, max: number): number;
  586. /**
  587. * Calculates the shortest difference between two given angles given in degrees.
  588. * @param current current angle in degrees
  589. * @param target target angle in degrees
  590. * @returns the delta
  591. */
  592. static DeltaAngle(current: number, target: number): number;
  593. /**
  594. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  595. * @param tx value
  596. * @param length length
  597. * @returns The returned value will move back and forth between 0 and length
  598. */
  599. static PingPong(tx: number, length: number): number;
  600. /**
  601. * Interpolates between min and max with smoothing at the limits.
  602. *
  603. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  604. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  605. * @param from from
  606. * @param to to
  607. * @param tx value
  608. * @returns the smooth stepped value
  609. */
  610. static SmoothStep(from: number, to: number, tx: number): number;
  611. /**
  612. * Moves a value current towards target.
  613. *
  614. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  615. * Negative values of maxDelta pushes the value away from target.
  616. * @param current current value
  617. * @param target target value
  618. * @param maxDelta max distance to move
  619. * @returns resulting value
  620. */
  621. static MoveTowards(current: number, target: number, maxDelta: number): number;
  622. /**
  623. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  624. *
  625. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  626. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  627. * @param current current value
  628. * @param target target value
  629. * @param maxDelta max distance to move
  630. * @returns resulting angle
  631. */
  632. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  633. /**
  634. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  635. * @param start start value
  636. * @param end target value
  637. * @param amount amount to lerp between
  638. * @returns the lerped value
  639. */
  640. static Lerp(start: number, end: number, amount: number): number;
  641. /**
  642. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  643. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  644. * @param start start value
  645. * @param end target value
  646. * @param amount amount to lerp between
  647. * @returns the lerped value
  648. */
  649. static LerpAngle(start: number, end: number, amount: number): number;
  650. /**
  651. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  652. * @param a start value
  653. * @param b target value
  654. * @param value value between a and b
  655. * @returns the inverseLerp value
  656. */
  657. static InverseLerp(a: number, b: number, value: number): number;
  658. /**
  659. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  660. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  661. * @param value1 spline value
  662. * @param tangent1 spline value
  663. * @param value2 spline value
  664. * @param tangent2 spline value
  665. * @param amount input value
  666. * @returns hermite result
  667. */
  668. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  669. /**
  670. * Returns a random float number between and min and max values
  671. * @param min min value of random
  672. * @param max max value of random
  673. * @returns random value
  674. */
  675. static RandomRange(min: number, max: number): number;
  676. /**
  677. * This function returns percentage of a number in a given range.
  678. *
  679. * RangeToPercent(40,20,60) will return 0.5 (50%)
  680. * RangeToPercent(34,0,100) will return 0.34 (34%)
  681. * @param number to convert to percentage
  682. * @param min min range
  683. * @param max max range
  684. * @returns the percentage
  685. */
  686. static RangeToPercent(number: number, min: number, max: number): number;
  687. /**
  688. * This function returns number that corresponds to the percentage in a given range.
  689. *
  690. * PercentToRange(0.34,0,100) will return 34.
  691. * @param percent to convert to number
  692. * @param min min range
  693. * @param max max range
  694. * @returns the number
  695. */
  696. static PercentToRange(percent: number, min: number, max: number): number;
  697. /**
  698. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  699. * @param angle The angle to normalize in radian.
  700. * @return The converted angle.
  701. */
  702. static NormalizeRadians(angle: number): number;
  703. }
  704. }
  705. declare module BABYLON {
  706. /**
  707. * Constant used to convert a value to gamma space
  708. * @ignorenaming
  709. */
  710. export const ToGammaSpace: number;
  711. /**
  712. * Constant used to convert a value to linear space
  713. * @ignorenaming
  714. */
  715. export const ToLinearSpace = 2.2;
  716. /**
  717. * Constant used to define the minimal number value in Babylon.js
  718. * @ignorenaming
  719. */
  720. let Epsilon: number;
  721. }
  722. declare module BABYLON {
  723. /**
  724. * Class used to represent a viewport on screen
  725. */
  726. export class Viewport {
  727. /** viewport left coordinate */
  728. x: number;
  729. /** viewport top coordinate */
  730. y: number;
  731. /**viewport width */
  732. width: number;
  733. /** viewport height */
  734. height: number;
  735. /**
  736. * Creates a Viewport object located at (x, y) and sized (width, height)
  737. * @param x defines viewport left coordinate
  738. * @param y defines viewport top coordinate
  739. * @param width defines the viewport width
  740. * @param height defines the viewport height
  741. */
  742. constructor(
  743. /** viewport left coordinate */
  744. x: number,
  745. /** viewport top coordinate */
  746. y: number,
  747. /**viewport width */
  748. width: number,
  749. /** viewport height */
  750. height: number);
  751. /**
  752. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  753. * @param renderWidth defines the rendering width
  754. * @param renderHeight defines the rendering height
  755. * @returns a new Viewport
  756. */
  757. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  758. /**
  759. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  760. * @param renderWidth defines the rendering width
  761. * @param renderHeight defines the rendering height
  762. * @param ref defines the target viewport
  763. * @returns the current viewport
  764. */
  765. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  766. /**
  767. * Returns a new Viewport copied from the current one
  768. * @returns a new Viewport
  769. */
  770. clone(): Viewport;
  771. }
  772. }
  773. declare module BABYLON {
  774. /**
  775. * Class containing a set of static utilities functions for arrays.
  776. */
  777. export class ArrayTools {
  778. /**
  779. * Returns an array of the given size filled with element built from the given constructor and the paramters
  780. * @param size the number of element to construct and put in the array
  781. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  782. * @returns a new array filled with new objects
  783. */
  784. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  785. }
  786. }
  787. declare module BABYLON {
  788. /**
  789. * @hidden
  790. */
  791. export interface IColor4Like {
  792. r: float;
  793. g: float;
  794. b: float;
  795. a: float;
  796. }
  797. /**
  798. * @hidden
  799. */
  800. export interface IColor3Like {
  801. r: float;
  802. g: float;
  803. b: float;
  804. }
  805. /**
  806. * @hidden
  807. */
  808. export interface IVector4Like {
  809. x: float;
  810. y: float;
  811. z: float;
  812. w: float;
  813. }
  814. /**
  815. * @hidden
  816. */
  817. export interface IVector3Like {
  818. x: float;
  819. y: float;
  820. z: float;
  821. }
  822. /**
  823. * @hidden
  824. */
  825. export interface IVector2Like {
  826. x: float;
  827. y: float;
  828. }
  829. /**
  830. * @hidden
  831. */
  832. export interface IMatrixLike {
  833. toArray(): DeepImmutable<Float32Array>;
  834. updateFlag: int;
  835. }
  836. /**
  837. * @hidden
  838. */
  839. export interface IViewportLike {
  840. x: float;
  841. y: float;
  842. width: float;
  843. height: float;
  844. }
  845. /**
  846. * @hidden
  847. */
  848. export interface IPlaneLike {
  849. normal: IVector3Like;
  850. d: float;
  851. normalize(): void;
  852. }
  853. }
  854. declare module BABYLON {
  855. /**
  856. * Class representing a vector containing 2 coordinates
  857. */
  858. export class Vector2 {
  859. /** defines the first coordinate */
  860. x: number;
  861. /** defines the second coordinate */
  862. y: number;
  863. /**
  864. * Creates a new Vector2 from the given x and y coordinates
  865. * @param x defines the first coordinate
  866. * @param y defines the second coordinate
  867. */
  868. constructor(
  869. /** defines the first coordinate */
  870. x?: number,
  871. /** defines the second coordinate */
  872. y?: number);
  873. /**
  874. * Gets a string with the Vector2 coordinates
  875. * @returns a string with the Vector2 coordinates
  876. */
  877. toString(): string;
  878. /**
  879. * Gets class name
  880. * @returns the string "Vector2"
  881. */
  882. getClassName(): string;
  883. /**
  884. * Gets current vector hash code
  885. * @returns the Vector2 hash code as a number
  886. */
  887. getHashCode(): number;
  888. /**
  889. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  890. * @param array defines the source array
  891. * @param index defines the offset in source array
  892. * @returns the current Vector2
  893. */
  894. toArray(array: FloatArray, index?: number): Vector2;
  895. /**
  896. * Copy the current vector to an array
  897. * @returns a new array with 2 elements: the Vector2 coordinates.
  898. */
  899. asArray(): number[];
  900. /**
  901. * Sets the Vector2 coordinates with the given Vector2 coordinates
  902. * @param source defines the source Vector2
  903. * @returns the current updated Vector2
  904. */
  905. copyFrom(source: DeepImmutable<Vector2>): 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. copyFromFloats(x: number, y: number): Vector2;
  913. /**
  914. * Sets the Vector2 coordinates with the given floats
  915. * @param x defines the first coordinate
  916. * @param y defines the second coordinate
  917. * @returns the current updated Vector2
  918. */
  919. set(x: number, y: number): Vector2;
  920. /**
  921. * Add another vector with the current one
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  924. */
  925. add(otherVector: DeepImmutable<Vector2>): Vector2;
  926. /**
  927. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  928. * @param otherVector defines the other vector
  929. * @param result defines the target vector
  930. * @returns the unmodified current Vector2
  931. */
  932. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  933. /**
  934. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  935. * @param otherVector defines the other vector
  936. * @returns the current updated Vector2
  937. */
  938. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  939. /**
  940. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  941. * @param otherVector defines the other vector
  942. * @returns a new Vector2
  943. */
  944. addVector3(otherVector: Vector3): Vector2;
  945. /**
  946. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  947. * @param otherVector defines the other vector
  948. * @returns a new Vector2
  949. */
  950. subtract(otherVector: Vector2): Vector2;
  951. /**
  952. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  953. * @param otherVector defines the other vector
  954. * @param result defines the target vector
  955. * @returns the unmodified current Vector2
  956. */
  957. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  958. /**
  959. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  960. * @param otherVector defines the other vector
  961. * @returns the current updated Vector2
  962. */
  963. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  964. /**
  965. * Multiplies in place the current Vector2 coordinates by the given ones
  966. * @param otherVector defines the other vector
  967. * @returns the current updated Vector2
  968. */
  969. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  970. /**
  971. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  972. * @param otherVector defines the other vector
  973. * @returns a new Vector2
  974. */
  975. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  976. /**
  977. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  978. * @param otherVector defines the other vector
  979. * @param result defines the target vector
  980. * @returns the unmodified current Vector2
  981. */
  982. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  983. /**
  984. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  985. * @param x defines the first coordinate
  986. * @param y defines the second coordinate
  987. * @returns a new Vector2
  988. */
  989. multiplyByFloats(x: number, y: number): Vector2;
  990. /**
  991. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  992. * @param otherVector defines the other vector
  993. * @returns a new Vector2
  994. */
  995. divide(otherVector: Vector2): Vector2;
  996. /**
  997. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  998. * @param otherVector defines the other vector
  999. * @param result defines the target vector
  1000. * @returns the unmodified current Vector2
  1001. */
  1002. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1003. /**
  1004. * Divides the current Vector2 coordinates by the given ones
  1005. * @param otherVector defines the other vector
  1006. * @returns the current updated Vector2
  1007. */
  1008. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1009. /**
  1010. * Gets a new Vector2 with current Vector2 negated coordinates
  1011. * @returns a new Vector2
  1012. */
  1013. negate(): Vector2;
  1014. /**
  1015. * Multiply the Vector2 coordinates by scale
  1016. * @param scale defines the scaling factor
  1017. * @returns the current updated Vector2
  1018. */
  1019. scaleInPlace(scale: number): Vector2;
  1020. /**
  1021. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1022. * @param scale defines the scaling factor
  1023. * @returns a new Vector2
  1024. */
  1025. scale(scale: number): Vector2;
  1026. /**
  1027. * Scale the current Vector2 values by a factor 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. scaleToRef(scale: number, result: Vector2): Vector2;
  1033. /**
  1034. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1035. * @param scale defines the scale factor
  1036. * @param result defines the Vector2 object where to store the result
  1037. * @returns the unmodified current Vector2
  1038. */
  1039. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1040. /**
  1041. * Gets a boolean if two vectors are equals
  1042. * @param otherVector defines the other vector
  1043. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1044. */
  1045. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1046. /**
  1047. * Gets a boolean if two vectors are equals (using an epsilon value)
  1048. * @param otherVector defines the other vector
  1049. * @param epsilon defines the minimal distance to consider equality
  1050. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1051. */
  1052. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1053. /**
  1054. * Gets a new Vector2 from current Vector2 floored values
  1055. * @returns a new Vector2
  1056. */
  1057. floor(): Vector2;
  1058. /**
  1059. * Gets a new Vector2 from current Vector2 floored values
  1060. * @returns a new Vector2
  1061. */
  1062. fract(): Vector2;
  1063. /**
  1064. * Gets the length of the vector
  1065. * @returns the vector length (float)
  1066. */
  1067. length(): number;
  1068. /**
  1069. * Gets the vector squared length
  1070. * @returns the vector squared length (float)
  1071. */
  1072. lengthSquared(): number;
  1073. /**
  1074. * Normalize the vector
  1075. * @returns the current updated Vector2
  1076. */
  1077. normalize(): Vector2;
  1078. /**
  1079. * Gets a new Vector2 copied from the Vector2
  1080. * @returns a new Vector2
  1081. */
  1082. clone(): Vector2;
  1083. /**
  1084. * Gets a new Vector2(0, 0)
  1085. * @returns a new Vector2
  1086. */
  1087. static Zero(): Vector2;
  1088. /**
  1089. * Gets a new Vector2(1, 1)
  1090. * @returns a new Vector2
  1091. */
  1092. static One(): Vector2;
  1093. /**
  1094. * Gets a new Vector2 set 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. * @returns a new Vector2
  1098. */
  1099. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1100. /**
  1101. * Sets "result" from the given index element of the given array
  1102. * @param array defines the data source
  1103. * @param offset defines the offset in the data source
  1104. * @param result defines the target vector
  1105. */
  1106. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1107. /**
  1108. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1109. * @param value1 defines 1st point of control
  1110. * @param value2 defines 2nd point of control
  1111. * @param value3 defines 3rd point of control
  1112. * @param value4 defines 4th point of control
  1113. * @param amount defines the interpolation factor
  1114. * @returns a new Vector2
  1115. */
  1116. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1117. /**
  1118. * 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".
  1119. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1120. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1121. * @param value defines the value to clamp
  1122. * @param min defines the lower limit
  1123. * @param max defines the upper limit
  1124. * @returns a new Vector2
  1125. */
  1126. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1127. /**
  1128. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1129. * @param value1 defines the 1st control point
  1130. * @param tangent1 defines the outgoing tangent
  1131. * @param value2 defines the 2nd control point
  1132. * @param tangent2 defines the incoming tangent
  1133. * @param amount defines the interpolation factor
  1134. * @returns a new Vector2
  1135. */
  1136. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1137. /**
  1138. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1139. * @param start defines the start vector
  1140. * @param end defines the end vector
  1141. * @param amount defines the interpolation factor
  1142. * @returns a new Vector2
  1143. */
  1144. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1145. /**
  1146. * Gets the dot product of the vector "left" and the vector "right"
  1147. * @param left defines first vector
  1148. * @param right defines second vector
  1149. * @returns the dot product (float)
  1150. */
  1151. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1152. /**
  1153. * Returns a new Vector2 equal to the normalized given vector
  1154. * @param vector defines the vector to normalize
  1155. * @returns a new Vector2
  1156. */
  1157. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1158. /**
  1159. * Gets a new Vector2 set with the minimal 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 Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1165. /**
  1166. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1167. * @param left defines 1st vector
  1168. * @param right defines 2nd vector
  1169. * @returns a new Vector2
  1170. */
  1171. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1172. /**
  1173. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1174. * @param vector defines the vector to transform
  1175. * @param transformation defines the matrix to apply
  1176. * @returns a new Vector2
  1177. */
  1178. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1179. /**
  1180. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1181. * @param vector defines the vector to transform
  1182. * @param transformation defines the matrix to apply
  1183. * @param result defines the target vector
  1184. */
  1185. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1186. /**
  1187. * Determines if a given vector is included in a triangle
  1188. * @param p defines the vector to test
  1189. * @param p0 defines 1st triangle point
  1190. * @param p1 defines 2nd triangle point
  1191. * @param p2 defines 3rd triangle point
  1192. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1193. */
  1194. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1195. /**
  1196. * Gets the distance between the vectors "value1" and "value2"
  1197. * @param value1 defines first vector
  1198. * @param value2 defines second vector
  1199. * @returns the distance between vectors
  1200. */
  1201. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1202. /**
  1203. * Returns the squared distance between the vectors "value1" and "value2"
  1204. * @param value1 defines first vector
  1205. * @param value2 defines second vector
  1206. * @returns the squared distance between vectors
  1207. */
  1208. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1209. /**
  1210. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1211. * @param value1 defines first vector
  1212. * @param value2 defines second vector
  1213. * @returns a new Vector2
  1214. */
  1215. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1216. /**
  1217. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1218. * @param p defines the middle point
  1219. * @param segA defines one point of the segment
  1220. * @param segB defines the other point of the segment
  1221. * @returns the shortest distance
  1222. */
  1223. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1224. }
  1225. /**
  1226. * Classed used to store (x,y,z) vector representation
  1227. * A Vector3 is the main object used in 3D geometry
  1228. * It can represent etiher the coordinates of a point the space, either a direction
  1229. * Reminder: js uses a left handed forward facing system
  1230. */
  1231. export class Vector3 {
  1232. /**
  1233. * Defines the first coordinates (on X axis)
  1234. */
  1235. x: number;
  1236. /**
  1237. * Defines the second coordinates (on Y axis)
  1238. */
  1239. y: number;
  1240. /**
  1241. * Defines the third coordinates (on Z axis)
  1242. */
  1243. z: number;
  1244. private static _UpReadOnly;
  1245. private static _ZeroReadOnly;
  1246. /**
  1247. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1248. * @param x defines the first coordinates (on X axis)
  1249. * @param y defines the second coordinates (on Y axis)
  1250. * @param z defines the third coordinates (on Z axis)
  1251. */
  1252. constructor(
  1253. /**
  1254. * Defines the first coordinates (on X axis)
  1255. */
  1256. x?: number,
  1257. /**
  1258. * Defines the second coordinates (on Y axis)
  1259. */
  1260. y?: number,
  1261. /**
  1262. * Defines the third coordinates (on Z axis)
  1263. */
  1264. z?: number);
  1265. /**
  1266. * Creates a string representation of the Vector3
  1267. * @returns a string with the Vector3 coordinates.
  1268. */
  1269. toString(): string;
  1270. /**
  1271. * Gets the class name
  1272. * @returns the string "Vector3"
  1273. */
  1274. getClassName(): string;
  1275. /**
  1276. * Creates the Vector3 hash code
  1277. * @returns a number which tends to be unique between Vector3 instances
  1278. */
  1279. getHashCode(): number;
  1280. /**
  1281. * Creates an array containing three elements : the coordinates of the Vector3
  1282. * @returns a new array of numbers
  1283. */
  1284. asArray(): number[];
  1285. /**
  1286. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1287. * @param array defines the destination array
  1288. * @param index defines the offset in the destination array
  1289. * @returns the current Vector3
  1290. */
  1291. toArray(array: FloatArray, index?: number): Vector3;
  1292. /**
  1293. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1294. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1295. */
  1296. toQuaternion(): Quaternion;
  1297. /**
  1298. * Adds the given vector to the current Vector3
  1299. * @param otherVector defines the second operand
  1300. * @returns the current updated Vector3
  1301. */
  1302. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1303. /**
  1304. * Adds the given coordinates to the current Vector3
  1305. * @param x defines the x coordinate of the operand
  1306. * @param y defines the y coordinate of the operand
  1307. * @param z defines the z coordinate of the operand
  1308. * @returns the current updated Vector3
  1309. */
  1310. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1311. /**
  1312. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1313. * @param otherVector defines the second operand
  1314. * @returns the resulting Vector3
  1315. */
  1316. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1317. /**
  1318. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1319. * @param otherVector defines the second operand
  1320. * @param result defines the Vector3 object where to store the result
  1321. * @returns the current Vector3
  1322. */
  1323. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1324. /**
  1325. * Subtract the given vector from the current Vector3
  1326. * @param otherVector defines the second operand
  1327. * @returns the current updated Vector3
  1328. */
  1329. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1330. /**
  1331. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1332. * @param otherVector defines the second operand
  1333. * @returns the resulting Vector3
  1334. */
  1335. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1336. /**
  1337. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1338. * @param otherVector defines the second operand
  1339. * @param result defines the Vector3 object where to store the result
  1340. * @returns the current Vector3
  1341. */
  1342. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1343. /**
  1344. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1345. * @param x defines the x coordinate of the operand
  1346. * @param y defines the y coordinate of the operand
  1347. * @param z defines the z coordinate of the operand
  1348. * @returns the resulting Vector3
  1349. */
  1350. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1351. /**
  1352. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1353. * @param x defines the x coordinate of the operand
  1354. * @param y defines the y coordinate of the operand
  1355. * @param z defines the z coordinate of the operand
  1356. * @param result defines the Vector3 object where to store the result
  1357. * @returns the current Vector3
  1358. */
  1359. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1360. /**
  1361. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1362. * @returns a new Vector3
  1363. */
  1364. negate(): Vector3;
  1365. /**
  1366. * Multiplies the Vector3 coordinates by the float "scale"
  1367. * @param scale defines the multiplier factor
  1368. * @returns the current updated Vector3
  1369. */
  1370. scaleInPlace(scale: number): Vector3;
  1371. /**
  1372. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1373. * @param scale defines the multiplier factor
  1374. * @returns a new Vector3
  1375. */
  1376. scale(scale: number): Vector3;
  1377. /**
  1378. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1379. * @param scale defines the multiplier factor
  1380. * @param result defines the Vector3 object where to store the result
  1381. * @returns the current Vector3
  1382. */
  1383. scaleToRef(scale: number, result: Vector3): Vector3;
  1384. /**
  1385. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1386. * @param scale defines the scale factor
  1387. * @param result defines the Vector3 object where to store the result
  1388. * @returns the unmodified current Vector3
  1389. */
  1390. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1391. /**
  1392. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1393. * @param otherVector defines the second operand
  1394. * @returns true if both vectors are equals
  1395. */
  1396. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1397. /**
  1398. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1399. * @param otherVector defines the second operand
  1400. * @param epsilon defines the minimal distance to define values as equals
  1401. * @returns true if both vectors are distant less than epsilon
  1402. */
  1403. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1404. /**
  1405. * Returns true if the current Vector3 coordinates equals the given floats
  1406. * @param x defines the x coordinate of the operand
  1407. * @param y defines the y coordinate of the operand
  1408. * @param z defines the z coordinate of the operand
  1409. * @returns true if both vectors are equals
  1410. */
  1411. equalsToFloats(x: number, y: number, z: number): boolean;
  1412. /**
  1413. * Multiplies the current Vector3 coordinates by the given ones
  1414. * @param otherVector defines the second operand
  1415. * @returns the current updated Vector3
  1416. */
  1417. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1418. /**
  1419. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1420. * @param otherVector defines the second operand
  1421. * @returns the new Vector3
  1422. */
  1423. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1424. /**
  1425. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1426. * @param otherVector defines the second operand
  1427. * @param result defines the Vector3 object where to store the result
  1428. * @returns the current Vector3
  1429. */
  1430. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1431. /**
  1432. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1433. * @param x defines the x coordinate of the operand
  1434. * @param y defines the y coordinate of the operand
  1435. * @param z defines the z coordinate of the operand
  1436. * @returns the new Vector3
  1437. */
  1438. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1439. /**
  1440. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1441. * @param otherVector defines the second operand
  1442. * @returns the new Vector3
  1443. */
  1444. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1447. * @param otherVector defines the second operand
  1448. * @param result defines the Vector3 object where to store the result
  1449. * @returns the current Vector3
  1450. */
  1451. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1452. /**
  1453. * Divides the current Vector3 coordinates by the given ones.
  1454. * @param otherVector defines the second operand
  1455. * @returns the current updated Vector3
  1456. */
  1457. divideInPlace(otherVector: Vector3): Vector3;
  1458. /**
  1459. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1460. * @param other defines the second operand
  1461. * @returns the current updated Vector3
  1462. */
  1463. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1464. /**
  1465. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1466. * @param other defines the second operand
  1467. * @returns the current updated Vector3
  1468. */
  1469. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1470. /**
  1471. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1472. * @param x defines the x coordinate of the operand
  1473. * @param y defines the y coordinate of the operand
  1474. * @param z defines the z coordinate of the operand
  1475. * @returns the current updated Vector3
  1476. */
  1477. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1478. /**
  1479. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1480. * @param x defines the x coordinate of the operand
  1481. * @param y defines the y coordinate of the operand
  1482. * @param z defines the z coordinate of the operand
  1483. * @returns the current updated Vector3
  1484. */
  1485. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1486. /**
  1487. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1488. * Check if is non uniform within a certain amount of decimal places to account for this
  1489. * @param epsilon the amount the values can differ
  1490. * @returns if the the vector is non uniform to a certain number of decimal places
  1491. */
  1492. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1493. /**
  1494. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1495. */
  1496. readonly isNonUniform: boolean;
  1497. /**
  1498. * Gets a new Vector3 from current Vector3 floored values
  1499. * @returns a new Vector3
  1500. */
  1501. floor(): Vector3;
  1502. /**
  1503. * Gets a new Vector3 from current Vector3 floored values
  1504. * @returns a new Vector3
  1505. */
  1506. fract(): Vector3;
  1507. /**
  1508. * Gets the length of the Vector3
  1509. * @returns the length of the Vector3
  1510. */
  1511. length(): number;
  1512. /**
  1513. * Gets the squared length of the Vector3
  1514. * @returns squared length of the Vector3
  1515. */
  1516. lengthSquared(): number;
  1517. /**
  1518. * Normalize the current Vector3.
  1519. * Please note that this is an in place operation.
  1520. * @returns the current updated Vector3
  1521. */
  1522. normalize(): Vector3;
  1523. /**
  1524. * Reorders the x y z properties of the vector in place
  1525. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1526. * @returns the current updated vector
  1527. */
  1528. reorderInPlace(order: string): this;
  1529. /**
  1530. * Rotates the vector around 0,0,0 by a quaternion
  1531. * @param quaternion the rotation quaternion
  1532. * @param result vector to store the result
  1533. * @returns the resulting vector
  1534. */
  1535. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1536. /**
  1537. * Rotates a vector around a given point
  1538. * @param quaternion the rotation quaternion
  1539. * @param point the point to rotate around
  1540. * @param result vector to store the result
  1541. * @returns the resulting vector
  1542. */
  1543. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1544. /**
  1545. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1546. * The cross product is then orthogonal to both current and "other"
  1547. * @param other defines the right operand
  1548. * @returns the cross product
  1549. */
  1550. cross(other: Vector3): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 with the given input length.
  1553. * Please note that this is an in place operation.
  1554. * @param len the length of the vector
  1555. * @returns the current updated Vector3
  1556. */
  1557. normalizeFromLength(len: number): Vector3;
  1558. /**
  1559. * Normalize the current Vector3 to a new vector
  1560. * @returns the new Vector3
  1561. */
  1562. normalizeToNew(): Vector3;
  1563. /**
  1564. * Normalize the current Vector3 to the reference
  1565. * @param reference define the Vector3 to update
  1566. * @returns the updated Vector3
  1567. */
  1568. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1569. /**
  1570. * Creates a new Vector3 copied from the current Vector3
  1571. * @returns the new Vector3
  1572. */
  1573. clone(): Vector3;
  1574. /**
  1575. * Copies the given vector coordinates to the current Vector3 ones
  1576. * @param source defines the source Vector3
  1577. * @returns the current updated Vector3
  1578. */
  1579. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1580. /**
  1581. * Copies the given floats to the current Vector3 coordinates
  1582. * @param x defines the x coordinate of the operand
  1583. * @param y defines the y coordinate of the operand
  1584. * @param z defines the z coordinate of the operand
  1585. * @returns the current updated Vector3
  1586. */
  1587. copyFromFloats(x: number, y: number, z: number): Vector3;
  1588. /**
  1589. * Copies the given floats to the current Vector3 coordinates
  1590. * @param x defines the x coordinate of the operand
  1591. * @param y defines the y coordinate of the operand
  1592. * @param z defines the z coordinate of the operand
  1593. * @returns the current updated Vector3
  1594. */
  1595. set(x: number, y: number, z: number): Vector3;
  1596. /**
  1597. * Copies the given float to the current Vector3 coordinates
  1598. * @param v defines the x, y and z coordinates of the operand
  1599. * @returns the current updated Vector3
  1600. */
  1601. setAll(v: number): Vector3;
  1602. /**
  1603. * Get the clip factor between two vectors
  1604. * @param vector0 defines the first operand
  1605. * @param vector1 defines the second operand
  1606. * @param axis defines the axis to use
  1607. * @param size defines the size along the axis
  1608. * @returns the clip factor
  1609. */
  1610. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1611. /**
  1612. * Get angle between two vectors
  1613. * @param vector0 angle between vector0 and vector1
  1614. * @param vector1 angle between vector0 and vector1
  1615. * @param normal direction of the normal
  1616. * @return the angle between vector0 and vector1
  1617. */
  1618. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1619. /**
  1620. * Returns a new Vector3 set from the index "offset" of the given array
  1621. * @param array defines the source array
  1622. * @param offset defines the offset in the source array
  1623. * @returns the new Vector3
  1624. */
  1625. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1626. /**
  1627. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1628. * This function is deprecated. Use FromArray instead
  1629. * @param array defines the source array
  1630. * @param offset defines the offset in the source array
  1631. * @returns the new Vector3
  1632. */
  1633. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1634. /**
  1635. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1636. * @param array defines the source array
  1637. * @param offset defines the offset in the source array
  1638. * @param result defines the Vector3 where to store the result
  1639. */
  1640. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1641. /**
  1642. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1643. * This function is deprecated. Use FromArrayToRef instead.
  1644. * @param array defines the source array
  1645. * @param offset defines the offset in the source array
  1646. * @param result defines the Vector3 where to store the result
  1647. */
  1648. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1649. /**
  1650. * Sets the given vector "result" with the given floats.
  1651. * @param x defines the x coordinate of the source
  1652. * @param y defines the y coordinate of the source
  1653. * @param z defines the z coordinate of the source
  1654. * @param result defines the Vector3 where to store the result
  1655. */
  1656. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1657. /**
  1658. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1659. * @returns a new empty Vector3
  1660. */
  1661. static Zero(): Vector3;
  1662. /**
  1663. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1664. * @returns a new unit Vector3
  1665. */
  1666. static One(): Vector3;
  1667. /**
  1668. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1669. * @returns a new up Vector3
  1670. */
  1671. static Up(): Vector3;
  1672. /**
  1673. * Gets a up Vector3 that must not be updated
  1674. */
  1675. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1676. /**
  1677. * Gets a zero Vector3 that must not be updated
  1678. */
  1679. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1680. /**
  1681. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1682. * @returns a new down Vector3
  1683. */
  1684. static Down(): Vector3;
  1685. /**
  1686. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1687. * @returns a new forward Vector3
  1688. */
  1689. static Forward(): Vector3;
  1690. /**
  1691. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1692. * @returns a new forward Vector3
  1693. */
  1694. static Backward(): Vector3;
  1695. /**
  1696. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1697. * @returns a new right Vector3
  1698. */
  1699. static Right(): Vector3;
  1700. /**
  1701. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1702. * @returns a new left Vector3
  1703. */
  1704. static Left(): Vector3;
  1705. /**
  1706. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1707. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1708. * @param vector defines the Vector3 to transform
  1709. * @param transformation defines the transformation matrix
  1710. * @returns the transformed Vector3
  1711. */
  1712. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1713. /**
  1714. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1715. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1716. * @param vector defines the Vector3 to transform
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1723. * This method computes tranformed coordinates only, not transformed direction vectors
  1724. * @param x define the x coordinate of the source vector
  1725. * @param y define the y coordinate of the source vector
  1726. * @param z define the z coordinate of the source vector
  1727. * @param transformation defines the transformation matrix
  1728. * @param result defines the Vector3 where to store the result
  1729. */
  1730. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1731. /**
  1732. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1733. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1734. * @param vector defines the Vector3 to transform
  1735. * @param transformation defines the transformation matrix
  1736. * @returns the new Vector3
  1737. */
  1738. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1739. /**
  1740. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1741. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1742. * @param vector defines the Vector3 to transform
  1743. * @param transformation defines the transformation matrix
  1744. * @param result defines the Vector3 where to store the result
  1745. */
  1746. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1747. /**
  1748. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1749. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1750. * @param x define the x coordinate of the source vector
  1751. * @param y define the y coordinate of the source vector
  1752. * @param z define the z coordinate of the source vector
  1753. * @param transformation defines the transformation matrix
  1754. * @param result defines the Vector3 where to store the result
  1755. */
  1756. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1757. /**
  1758. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1759. * @param value1 defines the first control point
  1760. * @param value2 defines the second control point
  1761. * @param value3 defines the third control point
  1762. * @param value4 defines the fourth control point
  1763. * @param amount defines the amount on the spline to use
  1764. * @returns the new Vector3
  1765. */
  1766. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1767. /**
  1768. * 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"
  1769. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1770. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1771. * @param value defines the current value
  1772. * @param min defines the lower range value
  1773. * @param max defines the upper range value
  1774. * @returns the new Vector3
  1775. */
  1776. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1777. /**
  1778. * 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"
  1779. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1780. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1781. * @param value defines the current value
  1782. * @param min defines the lower range value
  1783. * @param max defines the upper range value
  1784. * @param result defines the Vector3 where to store the result
  1785. */
  1786. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1787. /**
  1788. * Checks if a given vector is inside a specific range
  1789. * @param v defines the vector to test
  1790. * @param min defines the minimum range
  1791. * @param max defines the maximum range
  1792. */
  1793. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  1794. /**
  1795. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1796. * @param value1 defines the first control point
  1797. * @param tangent1 defines the first tangent vector
  1798. * @param value2 defines the second control point
  1799. * @param tangent2 defines the second tangent vector
  1800. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1801. * @returns the new Vector3
  1802. */
  1803. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1804. /**
  1805. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1806. * @param start defines the start value
  1807. * @param end defines the end value
  1808. * @param amount max defines amount between both (between 0 and 1)
  1809. * @returns the new Vector3
  1810. */
  1811. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1812. /**
  1813. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1814. * @param start defines the start value
  1815. * @param end defines the end value
  1816. * @param amount max defines amount between both (between 0 and 1)
  1817. * @param result defines the Vector3 where to store the result
  1818. */
  1819. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1820. /**
  1821. * Returns the dot product (float) between the vectors "left" and "right"
  1822. * @param left defines the left operand
  1823. * @param right defines the right operand
  1824. * @returns the dot product
  1825. */
  1826. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1827. /**
  1828. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1829. * The cross product is then orthogonal to both "left" and "right"
  1830. * @param left defines the left operand
  1831. * @param right defines the right operand
  1832. * @returns the cross product
  1833. */
  1834. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1835. /**
  1836. * Sets the given vector "result" with the cross product of "left" and "right"
  1837. * The cross product is then orthogonal to both "left" and "right"
  1838. * @param left defines the left operand
  1839. * @param right defines the right operand
  1840. * @param result defines the Vector3 where to store the result
  1841. */
  1842. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1843. /**
  1844. * Returns a new Vector3 as the normalization of the given vector
  1845. * @param vector defines the Vector3 to normalize
  1846. * @returns the new Vector3
  1847. */
  1848. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1849. /**
  1850. * Sets the given vector "result" with the normalization of the given first vector
  1851. * @param vector defines the Vector3 to normalize
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1855. /**
  1856. * Project a Vector3 onto screen space
  1857. * @param vector defines the Vector3 to project
  1858. * @param world defines the world matrix to use
  1859. * @param transform defines the transform (view x projection) matrix to use
  1860. * @param viewport defines the screen viewport to use
  1861. * @returns the new Vector3
  1862. */
  1863. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1864. /** @hidden */
  1865. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  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 transform defines the transform (view x projection) matrix to use
  1873. * @returns the new Vector3
  1874. */
  1875. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1876. /**
  1877. * Unproject from screen space to object space
  1878. * @param source defines the screen space Vector3 to use
  1879. * @param viewportWidth defines the current width of the viewport
  1880. * @param viewportHeight defines the current height of the viewport
  1881. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1882. * @param view defines the view matrix to use
  1883. * @param projection defines the projection matrix to use
  1884. * @returns the new Vector3
  1885. */
  1886. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1887. /**
  1888. * Unproject from screen space to object space
  1889. * @param source defines the screen space Vector3 to use
  1890. * @param viewportWidth defines the current width of the viewport
  1891. * @param viewportHeight defines the current height of the viewport
  1892. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1893. * @param view defines the view matrix to use
  1894. * @param projection defines the projection matrix to use
  1895. * @param result defines the Vector3 where to store the result
  1896. */
  1897. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1898. /**
  1899. * Unproject from screen space to object space
  1900. * @param sourceX defines the screen space x coordinate to use
  1901. * @param sourceY defines the screen space y coordinate to use
  1902. * @param sourceZ defines the screen space z coordinate to use
  1903. * @param viewportWidth defines the current width of the viewport
  1904. * @param viewportHeight defines the current height of the viewport
  1905. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1906. * @param view defines the view matrix to use
  1907. * @param projection defines the projection matrix to use
  1908. * @param result defines the Vector3 where to store the result
  1909. */
  1910. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1911. /**
  1912. * Gets the minimal coordinate values between two Vector3
  1913. * @param left defines the first operand
  1914. * @param right defines the second operand
  1915. * @returns the new Vector3
  1916. */
  1917. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1918. /**
  1919. * Gets the maximal coordinate values between two Vector3
  1920. * @param left defines the first operand
  1921. * @param right defines the second operand
  1922. * @returns the new Vector3
  1923. */
  1924. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1925. /**
  1926. * Returns the distance between the vectors "value1" and "value2"
  1927. * @param value1 defines the first operand
  1928. * @param value2 defines the second operand
  1929. * @returns the distance
  1930. */
  1931. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1932. /**
  1933. * Returns the squared distance between the vectors "value1" and "value2"
  1934. * @param value1 defines the first operand
  1935. * @param value2 defines the second operand
  1936. * @returns the squared distance
  1937. */
  1938. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1939. /**
  1940. * Returns a new Vector3 located at the center between "value1" and "value2"
  1941. * @param value1 defines the first operand
  1942. * @param value2 defines the second operand
  1943. * @returns the new Vector3
  1944. */
  1945. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1946. /**
  1947. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1948. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1949. * to something in order to rotate it from its local system to the given target system
  1950. * Note: axis1, axis2 and axis3 are normalized during this operation
  1951. * @param axis1 defines the first axis
  1952. * @param axis2 defines the second axis
  1953. * @param axis3 defines the third axis
  1954. * @returns a new Vector3
  1955. */
  1956. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1957. /**
  1958. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1959. * @param axis1 defines the first axis
  1960. * @param axis2 defines the second axis
  1961. * @param axis3 defines the third axis
  1962. * @param ref defines the Vector3 where to store the result
  1963. */
  1964. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1965. }
  1966. /**
  1967. * Vector4 class created for EulerAngle class conversion to Quaternion
  1968. */
  1969. export class Vector4 {
  1970. /** x value of the vector */
  1971. x: number;
  1972. /** y value of the vector */
  1973. y: number;
  1974. /** z value of the vector */
  1975. z: number;
  1976. /** w value of the vector */
  1977. w: number;
  1978. /**
  1979. * Creates a Vector4 object from the given floats.
  1980. * @param x x value of the vector
  1981. * @param y y value of the vector
  1982. * @param z z value of the vector
  1983. * @param w w value of the vector
  1984. */
  1985. constructor(
  1986. /** x value of the vector */
  1987. x: number,
  1988. /** y value of the vector */
  1989. y: number,
  1990. /** z value of the vector */
  1991. z: number,
  1992. /** w value of the vector */
  1993. w: number);
  1994. /**
  1995. * Returns the string with the Vector4 coordinates.
  1996. * @returns a string containing all the vector values
  1997. */
  1998. toString(): string;
  1999. /**
  2000. * Returns the string "Vector4".
  2001. * @returns "Vector4"
  2002. */
  2003. getClassName(): string;
  2004. /**
  2005. * Returns the Vector4 hash code.
  2006. * @returns a unique hash code
  2007. */
  2008. getHashCode(): number;
  2009. /**
  2010. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2011. * @returns the resulting array
  2012. */
  2013. asArray(): number[];
  2014. /**
  2015. * Populates the given array from the given index with the Vector4 coordinates.
  2016. * @param array array to populate
  2017. * @param index index of the array to start at (default: 0)
  2018. * @returns the Vector4.
  2019. */
  2020. toArray(array: FloatArray, index?: number): Vector4;
  2021. /**
  2022. * Adds the given vector to the current Vector4.
  2023. * @param otherVector the vector to add
  2024. * @returns the updated Vector4.
  2025. */
  2026. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2027. /**
  2028. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2029. * @param otherVector the vector to add
  2030. * @returns the resulting vector
  2031. */
  2032. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2035. * @param otherVector the vector to add
  2036. * @param result the vector to store the result
  2037. * @returns the current Vector4.
  2038. */
  2039. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2040. /**
  2041. * Subtract in place the given vector from the current Vector4.
  2042. * @param otherVector the vector to subtract
  2043. * @returns the updated Vector4.
  2044. */
  2045. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2046. /**
  2047. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2048. * @param otherVector the vector to add
  2049. * @returns the new vector with the result
  2050. */
  2051. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2052. /**
  2053. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2054. * @param otherVector the vector to subtract
  2055. * @param result the vector to store the result
  2056. * @returns the current Vector4.
  2057. */
  2058. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2059. /**
  2060. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2061. */
  2062. /**
  2063. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2064. * @param x value to subtract
  2065. * @param y value to subtract
  2066. * @param z value to subtract
  2067. * @param w value to subtract
  2068. * @returns new vector containing the result
  2069. */
  2070. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2071. /**
  2072. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2073. * @param x value to subtract
  2074. * @param y value to subtract
  2075. * @param z value to subtract
  2076. * @param w value to subtract
  2077. * @param result the vector to store the result in
  2078. * @returns the current Vector4.
  2079. */
  2080. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2081. /**
  2082. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2083. * @returns a new vector with the negated values
  2084. */
  2085. negate(): Vector4;
  2086. /**
  2087. * Multiplies the current Vector4 coordinates by scale (float).
  2088. * @param scale the number to scale with
  2089. * @returns the updated Vector4.
  2090. */
  2091. scaleInPlace(scale: number): Vector4;
  2092. /**
  2093. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2094. * @param scale the number to scale with
  2095. * @returns a new vector with the result
  2096. */
  2097. scale(scale: number): Vector4;
  2098. /**
  2099. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2100. * @param scale the number to scale with
  2101. * @param result a vector to store the result in
  2102. * @returns the current Vector4.
  2103. */
  2104. scaleToRef(scale: number, result: Vector4): Vector4;
  2105. /**
  2106. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector4 object where to store the result
  2109. * @returns the unmodified current Vector4
  2110. */
  2111. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2112. /**
  2113. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2114. * @param otherVector the vector to compare against
  2115. * @returns true if they are equal
  2116. */
  2117. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2118. /**
  2119. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2120. * @param otherVector vector to compare against
  2121. * @param epsilon (Default: very small number)
  2122. * @returns true if they are equal
  2123. */
  2124. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2125. /**
  2126. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2127. * @param x x value to compare against
  2128. * @param y y value to compare against
  2129. * @param z z value to compare against
  2130. * @param w w value to compare against
  2131. * @returns true if equal
  2132. */
  2133. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2134. /**
  2135. * Multiplies in place the current Vector4 by the given one.
  2136. * @param otherVector vector to multiple with
  2137. * @returns the updated Vector4.
  2138. */
  2139. multiplyInPlace(otherVector: Vector4): Vector4;
  2140. /**
  2141. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2142. * @param otherVector vector to multiple with
  2143. * @returns resulting new vector
  2144. */
  2145. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2146. /**
  2147. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2148. * @param otherVector vector to multiple with
  2149. * @param result vector to store the result
  2150. * @returns the current Vector4.
  2151. */
  2152. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2153. /**
  2154. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2155. * @param x x value multiply with
  2156. * @param y y value multiply with
  2157. * @param z z value multiply with
  2158. * @param w w value multiply with
  2159. * @returns resulting new vector
  2160. */
  2161. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2162. /**
  2163. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2164. * @param otherVector vector to devide with
  2165. * @returns resulting new vector
  2166. */
  2167. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2170. * @param otherVector vector to devide with
  2171. * @param result vector to store the result
  2172. * @returns the current Vector4.
  2173. */
  2174. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2175. /**
  2176. * Divides the current Vector3 coordinates by the given ones.
  2177. * @param otherVector vector to devide with
  2178. * @returns the updated Vector3.
  2179. */
  2180. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2181. /**
  2182. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2183. * @param other defines the second operand
  2184. * @returns the current updated Vector4
  2185. */
  2186. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2187. /**
  2188. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2189. * @param other defines the second operand
  2190. * @returns the current updated Vector4
  2191. */
  2192. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2193. /**
  2194. * Gets a new Vector4 from current Vector4 floored values
  2195. * @returns a new Vector4
  2196. */
  2197. floor(): Vector4;
  2198. /**
  2199. * Gets a new Vector4 from current Vector3 floored values
  2200. * @returns a new Vector4
  2201. */
  2202. fract(): Vector4;
  2203. /**
  2204. * Returns the Vector4 length (float).
  2205. * @returns the length
  2206. */
  2207. length(): number;
  2208. /**
  2209. * Returns the Vector4 squared length (float).
  2210. * @returns the length squared
  2211. */
  2212. lengthSquared(): number;
  2213. /**
  2214. * Normalizes in place the Vector4.
  2215. * @returns the updated Vector4.
  2216. */
  2217. normalize(): Vector4;
  2218. /**
  2219. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2220. * @returns this converted to a new vector3
  2221. */
  2222. toVector3(): Vector3;
  2223. /**
  2224. * Returns a new Vector4 copied from the current one.
  2225. * @returns the new cloned vector
  2226. */
  2227. clone(): Vector4;
  2228. /**
  2229. * Updates the current Vector4 with the given one coordinates.
  2230. * @param source the source vector to copy from
  2231. * @returns the updated Vector4.
  2232. */
  2233. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2234. /**
  2235. * Updates the current Vector4 coordinates with the given floats.
  2236. * @param x float to copy from
  2237. * @param y float to copy from
  2238. * @param z float to copy from
  2239. * @param w float to copy from
  2240. * @returns the updated Vector4.
  2241. */
  2242. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2243. /**
  2244. * Updates the current Vector4 coordinates with the given floats.
  2245. * @param x float to set from
  2246. * @param y float to set from
  2247. * @param z float to set from
  2248. * @param w float to set from
  2249. * @returns the updated Vector4.
  2250. */
  2251. set(x: number, y: number, z: number, w: number): Vector4;
  2252. /**
  2253. * Copies the given float to the current Vector3 coordinates
  2254. * @param v defines the x, y, z and w coordinates of the operand
  2255. * @returns the current updated Vector3
  2256. */
  2257. setAll(v: number): Vector4;
  2258. /**
  2259. * Returns a new Vector4 set from the starting index of the given array.
  2260. * @param array the array to pull values from
  2261. * @param offset the offset into the array to start at
  2262. * @returns the new vector
  2263. */
  2264. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2265. /**
  2266. * Updates the given vector "result" from the starting index of the given array.
  2267. * @param array the array to pull values from
  2268. * @param offset the offset into the array to start at
  2269. * @param result the vector to store the result in
  2270. */
  2271. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2272. /**
  2273. * Updates the given vector "result" from the starting index of the given Float32Array.
  2274. * @param array the array to pull values from
  2275. * @param offset the offset into the array to start at
  2276. * @param result the vector to store the result in
  2277. */
  2278. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2279. /**
  2280. * Updates the given vector "result" coordinates from the given floats.
  2281. * @param x float to set from
  2282. * @param y float to set from
  2283. * @param z float to set from
  2284. * @param w float to set from
  2285. * @param result the vector to the floats in
  2286. */
  2287. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2288. /**
  2289. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2290. * @returns the new vector
  2291. */
  2292. static Zero(): Vector4;
  2293. /**
  2294. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2295. * @returns the new vector
  2296. */
  2297. static One(): Vector4;
  2298. /**
  2299. * Returns a new normalized Vector4 from the given one.
  2300. * @param vector the vector to normalize
  2301. * @returns the vector
  2302. */
  2303. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2304. /**
  2305. * Updates the given vector "result" from the normalization of the given one.
  2306. * @param vector the vector to normalize
  2307. * @param result the vector to store the result in
  2308. */
  2309. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2310. /**
  2311. * Returns a vector with the minimum values from the left and right vectors
  2312. * @param left left vector to minimize
  2313. * @param right right vector to minimize
  2314. * @returns a new vector with the minimum of the left and right vector values
  2315. */
  2316. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2317. /**
  2318. * Returns a vector with the maximum values from the left and right vectors
  2319. * @param left left vector to maximize
  2320. * @param right right vector to maximize
  2321. * @returns a new vector with the maximum of the left and right vector values
  2322. */
  2323. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2324. /**
  2325. * Returns the distance (float) between the vectors "value1" and "value2".
  2326. * @param value1 value to calulate the distance between
  2327. * @param value2 value to calulate the distance between
  2328. * @return the distance between the two vectors
  2329. */
  2330. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2331. /**
  2332. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2333. * @param value1 value to calulate the distance between
  2334. * @param value2 value to calulate the distance between
  2335. * @return the distance between the two vectors squared
  2336. */
  2337. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2338. /**
  2339. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2340. * @param value1 value to calulate the center between
  2341. * @param value2 value to calulate the center between
  2342. * @return the center between the two vectors
  2343. */
  2344. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2345. /**
  2346. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2347. * This methods computes transformed normalized direction vectors only.
  2348. * @param vector the vector to transform
  2349. * @param transformation the transformation matrix to apply
  2350. * @returns the new vector
  2351. */
  2352. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2353. /**
  2354. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2355. * This methods computes transformed normalized direction vectors only.
  2356. * @param vector the vector to transform
  2357. * @param transformation the transformation matrix to apply
  2358. * @param result the vector to store the result in
  2359. */
  2360. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2361. /**
  2362. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2363. * This methods computes transformed normalized direction vectors only.
  2364. * @param x value to transform
  2365. * @param y value to transform
  2366. * @param z value to transform
  2367. * @param w value to transform
  2368. * @param transformation the transformation matrix to apply
  2369. * @param result the vector to store the results in
  2370. */
  2371. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2372. /**
  2373. * Creates a new Vector4 from a Vector3
  2374. * @param source defines the source data
  2375. * @param w defines the 4th component (default is 0)
  2376. * @returns a new Vector4
  2377. */
  2378. static FromVector3(source: Vector3, w?: number): Vector4;
  2379. }
  2380. /**
  2381. * Class used to store quaternion data
  2382. * @see https://en.wikipedia.org/wiki/Quaternion
  2383. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2384. */
  2385. export class Quaternion {
  2386. /** defines the first component (0 by default) */
  2387. x: number;
  2388. /** defines the second component (0 by default) */
  2389. y: number;
  2390. /** defines the third component (0 by default) */
  2391. z: number;
  2392. /** defines the fourth component (1.0 by default) */
  2393. w: number;
  2394. /**
  2395. * Creates a new Quaternion from the given floats
  2396. * @param x defines the first component (0 by default)
  2397. * @param y defines the second component (0 by default)
  2398. * @param z defines the third component (0 by default)
  2399. * @param w defines the fourth component (1.0 by default)
  2400. */
  2401. constructor(
  2402. /** defines the first component (0 by default) */
  2403. x?: number,
  2404. /** defines the second component (0 by default) */
  2405. y?: number,
  2406. /** defines the third component (0 by default) */
  2407. z?: number,
  2408. /** defines the fourth component (1.0 by default) */
  2409. w?: number);
  2410. /**
  2411. * Gets a string representation for the current quaternion
  2412. * @returns a string with the Quaternion coordinates
  2413. */
  2414. toString(): string;
  2415. /**
  2416. * Gets the class name of the quaternion
  2417. * @returns the string "Quaternion"
  2418. */
  2419. getClassName(): string;
  2420. /**
  2421. * Gets a hash code for this quaternion
  2422. * @returns the quaternion hash code
  2423. */
  2424. getHashCode(): number;
  2425. /**
  2426. * Copy the quaternion to an array
  2427. * @returns a new array populated with 4 elements from the quaternion coordinates
  2428. */
  2429. asArray(): number[];
  2430. /**
  2431. * Check if two quaternions are equals
  2432. * @param otherQuaternion defines the second operand
  2433. * @return true if the current quaternion and the given one coordinates are strictly equals
  2434. */
  2435. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2436. /**
  2437. * Clone the current quaternion
  2438. * @returns a new quaternion copied from the current one
  2439. */
  2440. clone(): Quaternion;
  2441. /**
  2442. * Copy a quaternion to the current one
  2443. * @param other defines the other quaternion
  2444. * @returns the updated current quaternion
  2445. */
  2446. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2447. /**
  2448. * Updates the current quaternion with the given float coordinates
  2449. * @param x defines the x coordinate
  2450. * @param y defines the y coordinate
  2451. * @param z defines the z coordinate
  2452. * @param w defines the w coordinate
  2453. * @returns the updated current quaternion
  2454. */
  2455. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2456. /**
  2457. * Updates the current quaternion from the given float coordinates
  2458. * @param x defines the x coordinate
  2459. * @param y defines the y coordinate
  2460. * @param z defines the z coordinate
  2461. * @param w defines the w coordinate
  2462. * @returns the updated current quaternion
  2463. */
  2464. set(x: number, y: number, z: number, w: number): Quaternion;
  2465. /**
  2466. * Adds two quaternions
  2467. * @param other defines the second operand
  2468. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2469. */
  2470. add(other: DeepImmutable<Quaternion>): Quaternion;
  2471. /**
  2472. * Add a quaternion to the current one
  2473. * @param other defines the quaternion to add
  2474. * @returns the current quaternion
  2475. */
  2476. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2477. /**
  2478. * Subtract two quaternions
  2479. * @param other defines the second operand
  2480. * @returns a new quaternion as the subtraction result of the given one from the current one
  2481. */
  2482. subtract(other: Quaternion): Quaternion;
  2483. /**
  2484. * Multiplies the current quaternion by a scale factor
  2485. * @param value defines the scale factor
  2486. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2487. */
  2488. scale(value: number): Quaternion;
  2489. /**
  2490. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2491. * @param scale defines the scale factor
  2492. * @param result defines the Quaternion object where to store the result
  2493. * @returns the unmodified current quaternion
  2494. */
  2495. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2496. /**
  2497. * Multiplies in place the current quaternion by a scale factor
  2498. * @param value defines the scale factor
  2499. * @returns the current modified quaternion
  2500. */
  2501. scaleInPlace(value: number): Quaternion;
  2502. /**
  2503. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2504. * @param scale defines the scale factor
  2505. * @param result defines the Quaternion object where to store the result
  2506. * @returns the unmodified current quaternion
  2507. */
  2508. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2509. /**
  2510. * Multiplies two quaternions
  2511. * @param q1 defines the second operand
  2512. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2513. */
  2514. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2515. /**
  2516. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2517. * @param q1 defines the second operand
  2518. * @param result defines the target quaternion
  2519. * @returns the current quaternion
  2520. */
  2521. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2522. /**
  2523. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2524. * @param q1 defines the second operand
  2525. * @returns the currentupdated quaternion
  2526. */
  2527. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2528. /**
  2529. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2530. * @param ref defines the target quaternion
  2531. * @returns the current quaternion
  2532. */
  2533. conjugateToRef(ref: Quaternion): Quaternion;
  2534. /**
  2535. * Conjugates in place (1-q) the current quaternion
  2536. * @returns the current updated quaternion
  2537. */
  2538. conjugateInPlace(): Quaternion;
  2539. /**
  2540. * Conjugates in place (1-q) the current quaternion
  2541. * @returns a new quaternion
  2542. */
  2543. conjugate(): Quaternion;
  2544. /**
  2545. * Gets length of current quaternion
  2546. * @returns the quaternion length (float)
  2547. */
  2548. length(): number;
  2549. /**
  2550. * Normalize in place the current quaternion
  2551. * @returns the current updated quaternion
  2552. */
  2553. normalize(): Quaternion;
  2554. /**
  2555. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2556. * @param order is a reserved parameter and is ignore for now
  2557. * @returns a new Vector3 containing the Euler angles
  2558. */
  2559. toEulerAngles(order?: string): Vector3;
  2560. /**
  2561. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2562. * @param result defines the vector which will be filled with the Euler angles
  2563. * @param order is a reserved parameter and is ignore for now
  2564. * @returns the current unchanged quaternion
  2565. */
  2566. toEulerAnglesToRef(result: Vector3): Quaternion;
  2567. /**
  2568. * Updates the given rotation matrix with the current quaternion values
  2569. * @param result defines the target matrix
  2570. * @returns the current unchanged quaternion
  2571. */
  2572. toRotationMatrix(result: Matrix): Quaternion;
  2573. /**
  2574. * Updates the current quaternion from the given rotation matrix values
  2575. * @param matrix defines the source matrix
  2576. * @returns the current updated quaternion
  2577. */
  2578. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2579. /**
  2580. * Creates a new quaternion from a rotation matrix
  2581. * @param matrix defines the source matrix
  2582. * @returns a new quaternion created from the given rotation matrix values
  2583. */
  2584. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2585. /**
  2586. * Updates the given quaternion with the given rotation matrix values
  2587. * @param matrix defines the source matrix
  2588. * @param result defines the target quaternion
  2589. */
  2590. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2591. /**
  2592. * Returns the dot product (float) between the quaternions "left" and "right"
  2593. * @param left defines the left operand
  2594. * @param right defines the right operand
  2595. * @returns the dot product
  2596. */
  2597. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2598. /**
  2599. * Checks if the two quaternions are close to each other
  2600. * @param quat0 defines the first quaternion to check
  2601. * @param quat1 defines the second quaternion to check
  2602. * @returns true if the two quaternions are close to each other
  2603. */
  2604. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2605. /**
  2606. * Creates an empty quaternion
  2607. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2608. */
  2609. static Zero(): Quaternion;
  2610. /**
  2611. * Inverse a given quaternion
  2612. * @param q defines the source quaternion
  2613. * @returns a new quaternion as the inverted current quaternion
  2614. */
  2615. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2616. /**
  2617. * Inverse a given quaternion
  2618. * @param q defines the source quaternion
  2619. * @param result the quaternion the result will be stored in
  2620. * @returns the result quaternion
  2621. */
  2622. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2623. /**
  2624. * Creates an identity quaternion
  2625. * @returns the identity quaternion
  2626. */
  2627. static Identity(): Quaternion;
  2628. /**
  2629. * Gets a boolean indicating if the given quaternion is identity
  2630. * @param quaternion defines the quaternion to check
  2631. * @returns true if the quaternion is identity
  2632. */
  2633. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2634. /**
  2635. * Creates a quaternion from a rotation around an axis
  2636. * @param axis defines the axis to use
  2637. * @param angle defines the angle to use
  2638. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2639. */
  2640. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2641. /**
  2642. * Creates a rotation around an axis and stores it into the given quaternion
  2643. * @param axis defines the axis to use
  2644. * @param angle defines the angle to use
  2645. * @param result defines the target quaternion
  2646. * @returns the target quaternion
  2647. */
  2648. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from data stored into an array
  2651. * @param array defines the data source
  2652. * @param offset defines the offset in the source array where the data starts
  2653. * @returns a new quaternion
  2654. */
  2655. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2656. /**
  2657. * Create a quaternion from Euler rotation angles
  2658. * @param x Pitch
  2659. * @param y Yaw
  2660. * @param z Roll
  2661. * @returns the new Quaternion
  2662. */
  2663. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2664. /**
  2665. * Updates a quaternion from Euler rotation angles
  2666. * @param x Pitch
  2667. * @param y Yaw
  2668. * @param z Roll
  2669. * @param result the quaternion to store the result
  2670. * @returns the updated quaternion
  2671. */
  2672. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2673. /**
  2674. * Create a quaternion from Euler rotation vector
  2675. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2676. * @returns the new Quaternion
  2677. */
  2678. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2679. /**
  2680. * Updates a quaternion from Euler rotation vector
  2681. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2682. * @param result the quaternion to store the result
  2683. * @returns the updated quaternion
  2684. */
  2685. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2686. /**
  2687. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2688. * @param yaw defines the rotation around Y axis
  2689. * @param pitch defines the rotation around X axis
  2690. * @param roll defines the rotation around Z axis
  2691. * @returns the new quaternion
  2692. */
  2693. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2694. /**
  2695. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2696. * @param yaw defines the rotation around Y axis
  2697. * @param pitch defines the rotation around X axis
  2698. * @param roll defines the rotation around Z axis
  2699. * @param result defines the target quaternion
  2700. */
  2701. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2702. /**
  2703. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2704. * @param alpha defines the rotation around first axis
  2705. * @param beta defines the rotation around second axis
  2706. * @param gamma defines the rotation around third axis
  2707. * @returns the new quaternion
  2708. */
  2709. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2710. /**
  2711. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2712. * @param alpha defines the rotation around first axis
  2713. * @param beta defines the rotation around second axis
  2714. * @param gamma defines the rotation around third axis
  2715. * @param result defines the target quaternion
  2716. */
  2717. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2718. /**
  2719. * 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)
  2720. * @param axis1 defines the first axis
  2721. * @param axis2 defines the second axis
  2722. * @param axis3 defines the third axis
  2723. * @returns the new quaternion
  2724. */
  2725. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2726. /**
  2727. * 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
  2728. * @param axis1 defines the first axis
  2729. * @param axis2 defines the second axis
  2730. * @param axis3 defines the third axis
  2731. * @param ref defines the target quaternion
  2732. */
  2733. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2734. /**
  2735. * Interpolates between two quaternions
  2736. * @param left defines first quaternion
  2737. * @param right defines second quaternion
  2738. * @param amount defines the gradient to use
  2739. * @returns the new interpolated quaternion
  2740. */
  2741. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2742. /**
  2743. * Interpolates between two quaternions and stores it into a target quaternion
  2744. * @param left defines first quaternion
  2745. * @param right defines second quaternion
  2746. * @param amount defines the gradient to use
  2747. * @param result defines the target quaternion
  2748. */
  2749. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2750. /**
  2751. * Interpolate between two quaternions using Hermite interpolation
  2752. * @param value1 defines first quaternion
  2753. * @param tangent1 defines the incoming tangent
  2754. * @param value2 defines second quaternion
  2755. * @param tangent2 defines the outgoing tangent
  2756. * @param amount defines the target quaternion
  2757. * @returns the new interpolated quaternion
  2758. */
  2759. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2760. }
  2761. /**
  2762. * Class used to store matrix data (4x4)
  2763. */
  2764. export class Matrix {
  2765. private static _updateFlagSeed;
  2766. private static _identityReadOnly;
  2767. private _isIdentity;
  2768. private _isIdentityDirty;
  2769. private _isIdentity3x2;
  2770. private _isIdentity3x2Dirty;
  2771. /**
  2772. * Gets the update flag of the matrix which is an unique number for the matrix.
  2773. * It will be incremented every time the matrix data change.
  2774. * You can use it to speed the comparison between two versions of the same matrix.
  2775. */
  2776. updateFlag: number;
  2777. private readonly _m;
  2778. /**
  2779. * Gets the internal data of the matrix
  2780. */
  2781. readonly m: DeepImmutable<Float32Array>;
  2782. /** @hidden */
  2783. _markAsUpdated(): void;
  2784. /** @hidden */
  2785. private _updateIdentityStatus;
  2786. /**
  2787. * Creates an empty matrix (filled with zeros)
  2788. */
  2789. constructor();
  2790. /**
  2791. * Check if the current matrix is identity
  2792. * @returns true is the matrix is the identity matrix
  2793. */
  2794. isIdentity(): boolean;
  2795. /**
  2796. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2797. * @returns true is the matrix is the identity matrix
  2798. */
  2799. isIdentityAs3x2(): boolean;
  2800. /**
  2801. * Gets the determinant of the matrix
  2802. * @returns the matrix determinant
  2803. */
  2804. determinant(): number;
  2805. /**
  2806. * Returns the matrix as a Float32Array
  2807. * @returns the matrix underlying array
  2808. */
  2809. toArray(): DeepImmutable<Float32Array>;
  2810. /**
  2811. * Returns the matrix as a Float32Array
  2812. * @returns the matrix underlying array.
  2813. */
  2814. asArray(): DeepImmutable<Float32Array>;
  2815. /**
  2816. * Inverts the current matrix in place
  2817. * @returns the current inverted matrix
  2818. */
  2819. invert(): Matrix;
  2820. /**
  2821. * Sets all the matrix elements to zero
  2822. * @returns the current matrix
  2823. */
  2824. reset(): Matrix;
  2825. /**
  2826. * Adds the current matrix with a second one
  2827. * @param other defines the matrix to add
  2828. * @returns a new matrix as the addition of the current matrix and the given one
  2829. */
  2830. add(other: DeepImmutable<Matrix>): Matrix;
  2831. /**
  2832. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2833. * @param other defines the matrix to add
  2834. * @param result defines the target matrix
  2835. * @returns the current matrix
  2836. */
  2837. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2838. /**
  2839. * Adds in place the given matrix to the current matrix
  2840. * @param other defines the second operand
  2841. * @returns the current updated matrix
  2842. */
  2843. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2844. /**
  2845. * Sets the given matrix to the current inverted Matrix
  2846. * @param other defines the target matrix
  2847. * @returns the unmodified current matrix
  2848. */
  2849. invertToRef(other: Matrix): Matrix;
  2850. /**
  2851. * add a value at the specified position in the current Matrix
  2852. * @param index the index of the value within the matrix. between 0 and 15.
  2853. * @param value the value to be added
  2854. * @returns the current updated matrix
  2855. */
  2856. addAtIndex(index: number, value: number): Matrix;
  2857. /**
  2858. * mutiply the specified position in the current Matrix by a value
  2859. * @param index the index of the value within the matrix. between 0 and 15.
  2860. * @param value the value to be added
  2861. * @returns the current updated matrix
  2862. */
  2863. multiplyAtIndex(index: number, value: number): Matrix;
  2864. /**
  2865. * Inserts the translation vector (using 3 floats) in the current matrix
  2866. * @param x defines the 1st component of the translation
  2867. * @param y defines the 2nd component of the translation
  2868. * @param z defines the 3rd component of the translation
  2869. * @returns the current updated matrix
  2870. */
  2871. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2872. /**
  2873. * Adds the translation vector (using 3 floats) in the current matrix
  2874. * @param x defines the 1st component of the translation
  2875. * @param y defines the 2nd component of the translation
  2876. * @param z defines the 3rd component of the translation
  2877. * @returns the current updated matrix
  2878. */
  2879. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2880. /**
  2881. * Inserts the translation vector in the current matrix
  2882. * @param vector3 defines the translation to insert
  2883. * @returns the current updated matrix
  2884. */
  2885. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2886. /**
  2887. * Gets the translation value of the current matrix
  2888. * @returns a new Vector3 as the extracted translation from the matrix
  2889. */
  2890. getTranslation(): Vector3;
  2891. /**
  2892. * Fill a Vector3 with the extracted translation from the matrix
  2893. * @param result defines the Vector3 where to store the translation
  2894. * @returns the current matrix
  2895. */
  2896. getTranslationToRef(result: Vector3): Matrix;
  2897. /**
  2898. * Remove rotation and scaling part from the matrix
  2899. * @returns the updated matrix
  2900. */
  2901. removeRotationAndScaling(): Matrix;
  2902. /**
  2903. * Multiply two matrices
  2904. * @param other defines the second operand
  2905. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2906. */
  2907. multiply(other: DeepImmutable<Matrix>): Matrix;
  2908. /**
  2909. * Copy the current matrix from the given one
  2910. * @param other defines the source matrix
  2911. * @returns the current updated matrix
  2912. */
  2913. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Populates the given array from the starting index with the current matrix values
  2916. * @param array defines the target array
  2917. * @param offset defines the offset in the target array where to start storing values
  2918. * @returns the current matrix
  2919. */
  2920. copyToArray(array: Float32Array, offset?: number): Matrix;
  2921. /**
  2922. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2923. * @param other defines the second operand
  2924. * @param result defines the matrix where to store the multiplication
  2925. * @returns the current matrix
  2926. */
  2927. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2928. /**
  2929. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2930. * @param other defines the second operand
  2931. * @param result defines the array where to store the multiplication
  2932. * @param offset defines the offset in the target array where to start storing values
  2933. * @returns the current matrix
  2934. */
  2935. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2936. /**
  2937. * Check equality between this matrix and a second one
  2938. * @param value defines the second matrix to compare
  2939. * @returns true is the current matrix and the given one values are strictly equal
  2940. */
  2941. equals(value: DeepImmutable<Matrix>): boolean;
  2942. /**
  2943. * Clone the current matrix
  2944. * @returns a new matrix from the current matrix
  2945. */
  2946. clone(): Matrix;
  2947. /**
  2948. * Returns the name of the current matrix class
  2949. * @returns the string "Matrix"
  2950. */
  2951. getClassName(): string;
  2952. /**
  2953. * Gets the hash code of the current matrix
  2954. * @returns the hash code
  2955. */
  2956. getHashCode(): number;
  2957. /**
  2958. * Decomposes the current Matrix into a translation, rotation and scaling components
  2959. * @param scale defines the scale vector3 given as a reference to update
  2960. * @param rotation defines the rotation quaternion given as a reference to update
  2961. * @param translation defines the translation vector3 given as a reference to update
  2962. * @returns true if operation was successful
  2963. */
  2964. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  2965. /**
  2966. * Gets specific row of the matrix
  2967. * @param index defines the number of the row to get
  2968. * @returns the index-th row of the current matrix as a new Vector4
  2969. */
  2970. getRow(index: number): Nullable<Vector4>;
  2971. /**
  2972. * Sets the index-th row of the current matrix to the vector4 values
  2973. * @param index defines the number of the row to set
  2974. * @param row defines the target vector4
  2975. * @returns the updated current matrix
  2976. */
  2977. setRow(index: number, row: Vector4): Matrix;
  2978. /**
  2979. * Compute the transpose of the matrix
  2980. * @returns the new transposed matrix
  2981. */
  2982. transpose(): Matrix;
  2983. /**
  2984. * Compute the transpose of the matrix and store it in a given matrix
  2985. * @param result defines the target matrix
  2986. * @returns the current matrix
  2987. */
  2988. transposeToRef(result: Matrix): Matrix;
  2989. /**
  2990. * Sets the index-th row of the current matrix with the given 4 x float values
  2991. * @param index defines the row index
  2992. * @param x defines the x component to set
  2993. * @param y defines the y component to set
  2994. * @param z defines the z component to set
  2995. * @param w defines the w component to set
  2996. * @returns the updated current matrix
  2997. */
  2998. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  2999. /**
  3000. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3001. * @param scale defines the scale factor
  3002. * @returns a new matrix
  3003. */
  3004. scale(scale: number): Matrix;
  3005. /**
  3006. * Scale the current matrix values by a factor to a given result matrix
  3007. * @param scale defines the scale factor
  3008. * @param result defines the matrix to store the result
  3009. * @returns the current matrix
  3010. */
  3011. scaleToRef(scale: number, result: Matrix): Matrix;
  3012. /**
  3013. * Scale the current matrix values by a factor and add the result to a given matrix
  3014. * @param scale defines the scale factor
  3015. * @param result defines the Matrix to store the result
  3016. * @returns the current matrix
  3017. */
  3018. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3019. /**
  3020. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3021. * @param ref matrix to store the result
  3022. */
  3023. toNormalMatrix(ref: Matrix): void;
  3024. /**
  3025. * Gets only rotation part of the current matrix
  3026. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3027. */
  3028. getRotationMatrix(): Matrix;
  3029. /**
  3030. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3031. * @param result defines the target matrix to store data to
  3032. * @returns the current matrix
  3033. */
  3034. getRotationMatrixToRef(result: Matrix): Matrix;
  3035. /**
  3036. * Toggles model matrix from being right handed to left handed in place and vice versa
  3037. */
  3038. toggleModelMatrixHandInPlace(): void;
  3039. /**
  3040. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3041. */
  3042. toggleProjectionMatrixHandInPlace(): void;
  3043. /**
  3044. * Creates a matrix from an array
  3045. * @param array defines the source array
  3046. * @param offset defines an offset in the source array
  3047. * @returns a new Matrix set from the starting index of the given array
  3048. */
  3049. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3050. /**
  3051. * Copy the content of an array into a given matrix
  3052. * @param array defines the source array
  3053. * @param offset defines an offset in the source array
  3054. * @param result defines the target matrix
  3055. */
  3056. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3057. /**
  3058. * Stores an array into a matrix after having multiplied each component by a given factor
  3059. * @param array defines the source array
  3060. * @param offset defines the offset in the source array
  3061. * @param scale defines the scaling factor
  3062. * @param result defines the target matrix
  3063. */
  3064. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3065. /**
  3066. * Gets an identity matrix that must not be updated
  3067. */
  3068. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3069. /**
  3070. * Stores a list of values (16) inside a given matrix
  3071. * @param initialM11 defines 1st value of 1st row
  3072. * @param initialM12 defines 2nd value of 1st row
  3073. * @param initialM13 defines 3rd value of 1st row
  3074. * @param initialM14 defines 4th value of 1st row
  3075. * @param initialM21 defines 1st value of 2nd row
  3076. * @param initialM22 defines 2nd value of 2nd row
  3077. * @param initialM23 defines 3rd value of 2nd row
  3078. * @param initialM24 defines 4th value of 2nd row
  3079. * @param initialM31 defines 1st value of 3rd row
  3080. * @param initialM32 defines 2nd value of 3rd row
  3081. * @param initialM33 defines 3rd value of 3rd row
  3082. * @param initialM34 defines 4th value of 3rd row
  3083. * @param initialM41 defines 1st value of 4th row
  3084. * @param initialM42 defines 2nd value of 4th row
  3085. * @param initialM43 defines 3rd value of 4th row
  3086. * @param initialM44 defines 4th value of 4th row
  3087. * @param result defines the target matrix
  3088. */
  3089. 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;
  3090. /**
  3091. * Creates new matrix from a list of values (16)
  3092. * @param initialM11 defines 1st value of 1st row
  3093. * @param initialM12 defines 2nd value of 1st row
  3094. * @param initialM13 defines 3rd value of 1st row
  3095. * @param initialM14 defines 4th value of 1st row
  3096. * @param initialM21 defines 1st value of 2nd row
  3097. * @param initialM22 defines 2nd value of 2nd row
  3098. * @param initialM23 defines 3rd value of 2nd row
  3099. * @param initialM24 defines 4th value of 2nd row
  3100. * @param initialM31 defines 1st value of 3rd row
  3101. * @param initialM32 defines 2nd value of 3rd row
  3102. * @param initialM33 defines 3rd value of 3rd row
  3103. * @param initialM34 defines 4th value of 3rd row
  3104. * @param initialM41 defines 1st value of 4th row
  3105. * @param initialM42 defines 2nd value of 4th row
  3106. * @param initialM43 defines 3rd value of 4th row
  3107. * @param initialM44 defines 4th value of 4th row
  3108. * @returns the new matrix
  3109. */
  3110. 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;
  3111. /**
  3112. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3113. * @param scale defines the scale vector3
  3114. * @param rotation defines the rotation quaternion
  3115. * @param translation defines the translation vector3
  3116. * @returns a new matrix
  3117. */
  3118. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3119. /**
  3120. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3121. * @param scale defines the scale vector3
  3122. * @param rotation defines the rotation quaternion
  3123. * @param translation defines the translation vector3
  3124. * @param result defines the target matrix
  3125. */
  3126. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3127. /**
  3128. * Creates a new identity matrix
  3129. * @returns a new identity matrix
  3130. */
  3131. static Identity(): Matrix;
  3132. /**
  3133. * Creates a new identity matrix and stores the result in a given matrix
  3134. * @param result defines the target matrix
  3135. */
  3136. static IdentityToRef(result: Matrix): void;
  3137. /**
  3138. * Creates a new zero matrix
  3139. * @returns a new zero matrix
  3140. */
  3141. static Zero(): Matrix;
  3142. /**
  3143. * Creates a new rotation matrix for "angle" radians around the X axis
  3144. * @param angle defines the angle (in radians) to use
  3145. * @return the new matrix
  3146. */
  3147. static RotationX(angle: number): Matrix;
  3148. /**
  3149. * Creates a new matrix as the invert of a given matrix
  3150. * @param source defines the source matrix
  3151. * @returns the new matrix
  3152. */
  3153. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3154. /**
  3155. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3156. * @param angle defines the angle (in radians) to use
  3157. * @param result defines the target matrix
  3158. */
  3159. static RotationXToRef(angle: number, result: Matrix): void;
  3160. /**
  3161. * Creates a new rotation matrix for "angle" radians around the Y axis
  3162. * @param angle defines the angle (in radians) to use
  3163. * @return the new matrix
  3164. */
  3165. static RotationY(angle: number): Matrix;
  3166. /**
  3167. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3168. * @param angle defines the angle (in radians) to use
  3169. * @param result defines the target matrix
  3170. */
  3171. static RotationYToRef(angle: number, result: Matrix): void;
  3172. /**
  3173. * Creates a new rotation matrix for "angle" radians around the Z axis
  3174. * @param angle defines the angle (in radians) to use
  3175. * @return the new matrix
  3176. */
  3177. static RotationZ(angle: number): Matrix;
  3178. /**
  3179. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3180. * @param angle defines the angle (in radians) to use
  3181. * @param result defines the target matrix
  3182. */
  3183. static RotationZToRef(angle: number, result: Matrix): void;
  3184. /**
  3185. * Creates a new rotation matrix for "angle" radians around the given axis
  3186. * @param axis defines the axis to use
  3187. * @param angle defines the angle (in radians) to use
  3188. * @return the new matrix
  3189. */
  3190. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3191. /**
  3192. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3193. * @param axis defines the axis to use
  3194. * @param angle defines the angle (in radians) to use
  3195. * @param result defines the target matrix
  3196. */
  3197. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3198. /**
  3199. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3200. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3201. * @param from defines the vector to align
  3202. * @param to defines the vector to align to
  3203. * @param result defines the target matrix
  3204. */
  3205. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3206. /**
  3207. * Creates a rotation matrix
  3208. * @param yaw defines the yaw angle in radians (Y axis)
  3209. * @param pitch defines the pitch angle in radians (X axis)
  3210. * @param roll defines the roll angle in radians (X axis)
  3211. * @returns the new rotation matrix
  3212. */
  3213. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3214. /**
  3215. * Creates a rotation matrix and stores it in a given matrix
  3216. * @param yaw defines the yaw angle in radians (Y axis)
  3217. * @param pitch defines the pitch angle in radians (X axis)
  3218. * @param roll defines the roll angle in radians (X axis)
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3222. /**
  3223. * Creates a scaling matrix
  3224. * @param x defines the scale factor on X axis
  3225. * @param y defines the scale factor on Y axis
  3226. * @param z defines the scale factor on Z axis
  3227. * @returns the new matrix
  3228. */
  3229. static Scaling(x: number, y: number, z: number): Matrix;
  3230. /**
  3231. * Creates a scaling matrix and stores it in a given matrix
  3232. * @param x defines the scale factor on X axis
  3233. * @param y defines the scale factor on Y axis
  3234. * @param z defines the scale factor on Z axis
  3235. * @param result defines the target matrix
  3236. */
  3237. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3238. /**
  3239. * Creates a translation matrix
  3240. * @param x defines the translation on X axis
  3241. * @param y defines the translation on Y axis
  3242. * @param z defines the translationon Z axis
  3243. * @returns the new matrix
  3244. */
  3245. static Translation(x: number, y: number, z: number): Matrix;
  3246. /**
  3247. * Creates a translation matrix and stores it in a given matrix
  3248. * @param x defines the translation on X axis
  3249. * @param y defines the translation on Y axis
  3250. * @param z defines the translationon Z axis
  3251. * @param result defines the target matrix
  3252. */
  3253. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3254. /**
  3255. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3256. * @param startValue defines the start value
  3257. * @param endValue defines the end value
  3258. * @param gradient defines the gradient factor
  3259. * @returns the new matrix
  3260. */
  3261. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3262. /**
  3263. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3264. * @param startValue defines the start value
  3265. * @param endValue defines the end value
  3266. * @param gradient defines the gradient factor
  3267. * @param result defines the Matrix object where to store data
  3268. */
  3269. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3270. /**
  3271. * Builds a new matrix whose values are computed by:
  3272. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3273. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3274. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3275. * @param startValue defines the first matrix
  3276. * @param endValue defines the second matrix
  3277. * @param gradient defines the gradient between the two matrices
  3278. * @returns the new matrix
  3279. */
  3280. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3281. /**
  3282. * Update a matrix to values which are computed by:
  3283. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3284. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3285. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3286. * @param startValue defines the first matrix
  3287. * @param endValue defines the second matrix
  3288. * @param gradient defines the gradient between the two matrices
  3289. * @param result defines the target matrix
  3290. */
  3291. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3292. /**
  3293. * 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"
  3294. * This function works in left handed mode
  3295. * @param eye defines the final position of the entity
  3296. * @param target defines where the entity should look at
  3297. * @param up defines the up vector for the entity
  3298. * @returns the new matrix
  3299. */
  3300. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3301. /**
  3302. * 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".
  3303. * This function works in left handed mode
  3304. * @param eye defines the final position of the entity
  3305. * @param target defines where the entity should look at
  3306. * @param up defines the up vector for the entity
  3307. * @param result defines the target matrix
  3308. */
  3309. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3310. /**
  3311. * 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"
  3312. * This function works in right handed mode
  3313. * @param eye defines the final position of the entity
  3314. * @param target defines where the entity should look at
  3315. * @param up defines the up vector for the entity
  3316. * @returns the new matrix
  3317. */
  3318. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3319. /**
  3320. * 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".
  3321. * This function works in right handed mode
  3322. * @param eye defines the final position of the entity
  3323. * @param target defines where the entity should look at
  3324. * @param up defines the up vector for the entity
  3325. * @param result defines the target matrix
  3326. */
  3327. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3328. /**
  3329. * Create a left-handed orthographic projection matrix
  3330. * @param width defines the viewport width
  3331. * @param height defines the viewport height
  3332. * @param znear defines the near clip plane
  3333. * @param zfar defines the far clip plane
  3334. * @returns a new matrix as a left-handed orthographic projection matrix
  3335. */
  3336. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3337. /**
  3338. * Store a left-handed orthographic projection to a given matrix
  3339. * @param width defines the viewport width
  3340. * @param height defines the viewport height
  3341. * @param znear defines the near clip plane
  3342. * @param zfar defines the far clip plane
  3343. * @param result defines the target matrix
  3344. */
  3345. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3346. /**
  3347. * Create a left-handed orthographic projection matrix
  3348. * @param left defines the viewport left coordinate
  3349. * @param right defines the viewport right coordinate
  3350. * @param bottom defines the viewport bottom coordinate
  3351. * @param top defines the viewport top coordinate
  3352. * @param znear defines the near clip plane
  3353. * @param zfar defines the far clip plane
  3354. * @returns a new matrix as a left-handed orthographic projection matrix
  3355. */
  3356. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3357. /**
  3358. * Stores a left-handed orthographic projection into a given matrix
  3359. * @param left defines the viewport left coordinate
  3360. * @param right defines the viewport right coordinate
  3361. * @param bottom defines the viewport bottom coordinate
  3362. * @param top defines the viewport top coordinate
  3363. * @param znear defines the near clip plane
  3364. * @param zfar defines the far clip plane
  3365. * @param result defines the target matrix
  3366. */
  3367. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3368. /**
  3369. * Creates a right-handed orthographic projection matrix
  3370. * @param left defines the viewport left coordinate
  3371. * @param right defines the viewport right coordinate
  3372. * @param bottom defines the viewport bottom coordinate
  3373. * @param top defines the viewport top coordinate
  3374. * @param znear defines the near clip plane
  3375. * @param zfar defines the far clip plane
  3376. * @returns a new matrix as a right-handed orthographic projection matrix
  3377. */
  3378. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3379. /**
  3380. * Stores a right-handed orthographic projection into a given matrix
  3381. * @param left defines the viewport left coordinate
  3382. * @param right defines the viewport right coordinate
  3383. * @param bottom defines the viewport bottom coordinate
  3384. * @param top defines the viewport top coordinate
  3385. * @param znear defines the near clip plane
  3386. * @param zfar defines the far clip plane
  3387. * @param result defines the target matrix
  3388. */
  3389. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3390. /**
  3391. * Creates a left-handed perspective projection matrix
  3392. * @param width defines the viewport width
  3393. * @param height defines the viewport height
  3394. * @param znear defines the near clip plane
  3395. * @param zfar defines the far clip plane
  3396. * @returns a new matrix as a left-handed perspective projection matrix
  3397. */
  3398. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3399. /**
  3400. * Creates a left-handed perspective projection matrix
  3401. * @param fov defines the horizontal field of view
  3402. * @param aspect defines the aspect ratio
  3403. * @param znear defines the near clip plane
  3404. * @param zfar defines the far clip plane
  3405. * @returns a new matrix as a left-handed perspective projection matrix
  3406. */
  3407. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Stores a left-handed perspective projection into a given matrix
  3410. * @param fov defines the horizontal field of view
  3411. * @param aspect defines the aspect ratio
  3412. * @param znear defines the near clip plane
  3413. * @param zfar defines the far clip plane
  3414. * @param result defines the target matrix
  3415. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3416. */
  3417. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3418. /**
  3419. * Creates a right-handed perspective projection matrix
  3420. * @param fov defines the horizontal field of view
  3421. * @param aspect defines the aspect ratio
  3422. * @param znear defines the near clip plane
  3423. * @param zfar defines the far clip plane
  3424. * @returns a new matrix as a right-handed perspective projection matrix
  3425. */
  3426. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3427. /**
  3428. * Stores a right-handed perspective projection into a given matrix
  3429. * @param fov defines the horizontal field of view
  3430. * @param aspect defines the aspect ratio
  3431. * @param znear defines the near clip plane
  3432. * @param zfar defines the far clip plane
  3433. * @param result defines the target matrix
  3434. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3435. */
  3436. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3437. /**
  3438. * Stores a perspective projection for WebVR info a given matrix
  3439. * @param fov defines the field of view
  3440. * @param znear defines the near clip plane
  3441. * @param zfar defines the far clip plane
  3442. * @param result defines the target matrix
  3443. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3444. */
  3445. static PerspectiveFovWebVRToRef(fov: {
  3446. upDegrees: number;
  3447. downDegrees: number;
  3448. leftDegrees: number;
  3449. rightDegrees: number;
  3450. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3451. /**
  3452. * Computes a complete transformation matrix
  3453. * @param viewport defines the viewport to use
  3454. * @param world defines the world matrix
  3455. * @param view defines the view matrix
  3456. * @param projection defines the projection matrix
  3457. * @param zmin defines the near clip plane
  3458. * @param zmax defines the far clip plane
  3459. * @returns the transformation matrix
  3460. */
  3461. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3462. /**
  3463. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3464. * @param matrix defines the matrix to use
  3465. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3466. */
  3467. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3468. /**
  3469. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3470. * @param matrix defines the matrix to use
  3471. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3472. */
  3473. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3474. /**
  3475. * Compute the transpose of a given matrix
  3476. * @param matrix defines the matrix to transpose
  3477. * @returns the new matrix
  3478. */
  3479. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3480. /**
  3481. * Compute the transpose of a matrix and store it in a target matrix
  3482. * @param matrix defines the matrix to transpose
  3483. * @param result defines the target matrix
  3484. */
  3485. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3486. /**
  3487. * Computes a reflection matrix from a plane
  3488. * @param plane defines the reflection plane
  3489. * @returns a new matrix
  3490. */
  3491. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3492. /**
  3493. * Computes a reflection matrix from a plane
  3494. * @param plane defines the reflection plane
  3495. * @param result defines the target matrix
  3496. */
  3497. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  3498. /**
  3499. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3500. * @param xaxis defines the value of the 1st axis
  3501. * @param yaxis defines the value of the 2nd axis
  3502. * @param zaxis defines the value of the 3rd axis
  3503. * @param result defines the target matrix
  3504. */
  3505. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3506. /**
  3507. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3508. * @param quat defines the quaternion to use
  3509. * @param result defines the target matrix
  3510. */
  3511. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3512. }
  3513. /**
  3514. * @hidden
  3515. */
  3516. export class TmpVectors {
  3517. static Vector2: Vector2[];
  3518. static Vector3: Vector3[];
  3519. static Vector4: Vector4[];
  3520. static Quaternion: Quaternion[];
  3521. static Matrix: Matrix[];
  3522. }
  3523. }
  3524. declare module BABYLON {
  3525. /**
  3526. * Class used to hold a RBG color
  3527. */
  3528. export class Color3 {
  3529. /**
  3530. * Defines the red component (between 0 and 1, default is 0)
  3531. */
  3532. r: number;
  3533. /**
  3534. * Defines the green component (between 0 and 1, default is 0)
  3535. */
  3536. g: number;
  3537. /**
  3538. * Defines the blue component (between 0 and 1, default is 0)
  3539. */
  3540. b: number;
  3541. /**
  3542. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  3543. * @param r defines the red component (between 0 and 1, default is 0)
  3544. * @param g defines the green component (between 0 and 1, default is 0)
  3545. * @param b defines the blue component (between 0 and 1, default is 0)
  3546. */
  3547. constructor(
  3548. /**
  3549. * Defines the red component (between 0 and 1, default is 0)
  3550. */
  3551. r?: number,
  3552. /**
  3553. * Defines the green component (between 0 and 1, default is 0)
  3554. */
  3555. g?: number,
  3556. /**
  3557. * Defines the blue component (between 0 and 1, default is 0)
  3558. */
  3559. b?: number);
  3560. /**
  3561. * Creates a string with the Color3 current values
  3562. * @returns the string representation of the Color3 object
  3563. */
  3564. toString(): string;
  3565. /**
  3566. * Returns the string "Color3"
  3567. * @returns "Color3"
  3568. */
  3569. getClassName(): string;
  3570. /**
  3571. * Compute the Color3 hash code
  3572. * @returns an unique number that can be used to hash Color3 objects
  3573. */
  3574. getHashCode(): number;
  3575. /**
  3576. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  3577. * @param array defines the array where to store the r,g,b components
  3578. * @param index defines an optional index in the target array to define where to start storing values
  3579. * @returns the current Color3 object
  3580. */
  3581. toArray(array: FloatArray, index?: number): Color3;
  3582. /**
  3583. * Returns a new Color4 object from the current Color3 and the given alpha
  3584. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  3585. * @returns a new Color4 object
  3586. */
  3587. toColor4(alpha?: number): Color4;
  3588. /**
  3589. * Returns a new array populated with 3 numeric elements : red, green and blue values
  3590. * @returns the new array
  3591. */
  3592. asArray(): number[];
  3593. /**
  3594. * Returns the luminance value
  3595. * @returns a float value
  3596. */
  3597. toLuminance(): number;
  3598. /**
  3599. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  3600. * @param otherColor defines the second operand
  3601. * @returns the new Color3 object
  3602. */
  3603. multiply(otherColor: DeepImmutable<Color3>): Color3;
  3604. /**
  3605. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  3606. * @param otherColor defines the second operand
  3607. * @param result defines the Color3 object where to store the result
  3608. * @returns the current Color3
  3609. */
  3610. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3611. /**
  3612. * Determines equality between Color3 objects
  3613. * @param otherColor defines the second operand
  3614. * @returns true if the rgb values are equal to the given ones
  3615. */
  3616. equals(otherColor: DeepImmutable<Color3>): boolean;
  3617. /**
  3618. * Determines equality between the current Color3 object and a set of r,b,g values
  3619. * @param r defines the red component to check
  3620. * @param g defines the green component to check
  3621. * @param b defines the blue component to check
  3622. * @returns true if the rgb values are equal to the given ones
  3623. */
  3624. equalsFloats(r: number, g: number, b: number): boolean;
  3625. /**
  3626. * Multiplies in place each rgb value by scale
  3627. * @param scale defines the scaling factor
  3628. * @returns the updated Color3
  3629. */
  3630. scale(scale: number): Color3;
  3631. /**
  3632. * Multiplies the rgb values by scale and stores the result into "result"
  3633. * @param scale defines the scaling factor
  3634. * @param result defines the Color3 object where to store the result
  3635. * @returns the unmodified current Color3
  3636. */
  3637. scaleToRef(scale: number, result: Color3): Color3;
  3638. /**
  3639. * Scale the current Color3 values by a factor and add the result to a given Color3
  3640. * @param scale defines the scale factor
  3641. * @param result defines color to store the result into
  3642. * @returns the unmodified current Color3
  3643. */
  3644. scaleAndAddToRef(scale: number, result: Color3): Color3;
  3645. /**
  3646. * Clamps the rgb values by the min and max values and stores the result into "result"
  3647. * @param min defines minimum clamping value (default is 0)
  3648. * @param max defines maximum clamping value (default is 1)
  3649. * @param result defines color to store the result into
  3650. * @returns the original Color3
  3651. */
  3652. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  3653. /**
  3654. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  3655. * @param otherColor defines the second operand
  3656. * @returns the new Color3
  3657. */
  3658. add(otherColor: DeepImmutable<Color3>): Color3;
  3659. /**
  3660. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  3661. * @param otherColor defines the second operand
  3662. * @param result defines Color3 object to store the result into
  3663. * @returns the unmodified current Color3
  3664. */
  3665. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3666. /**
  3667. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  3668. * @param otherColor defines the second operand
  3669. * @returns the new Color3
  3670. */
  3671. subtract(otherColor: DeepImmutable<Color3>): Color3;
  3672. /**
  3673. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  3674. * @param otherColor defines the second operand
  3675. * @param result defines Color3 object to store the result into
  3676. * @returns the unmodified current Color3
  3677. */
  3678. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3679. /**
  3680. * Copy the current object
  3681. * @returns a new Color3 copied the current one
  3682. */
  3683. clone(): Color3;
  3684. /**
  3685. * Copies the rgb values from the source in the current Color3
  3686. * @param source defines the source Color3 object
  3687. * @returns the updated Color3 object
  3688. */
  3689. copyFrom(source: DeepImmutable<Color3>): Color3;
  3690. /**
  3691. * Updates the Color3 rgb values from the given floats
  3692. * @param r defines the red component to read from
  3693. * @param g defines the green component to read from
  3694. * @param b defines the blue component to read from
  3695. * @returns the current Color3 object
  3696. */
  3697. copyFromFloats(r: number, g: number, b: number): Color3;
  3698. /**
  3699. * Updates the Color3 rgb values from the given floats
  3700. * @param r defines the red component to read from
  3701. * @param g defines the green component to read from
  3702. * @param b defines the blue component to read from
  3703. * @returns the current Color3 object
  3704. */
  3705. set(r: number, g: number, b: number): Color3;
  3706. /**
  3707. * Compute the Color3 hexadecimal code as a string
  3708. * @returns a string containing the hexadecimal representation of the Color3 object
  3709. */
  3710. toHexString(): string;
  3711. /**
  3712. * Computes a new Color3 converted from the current one to linear space
  3713. * @returns a new Color3 object
  3714. */
  3715. toLinearSpace(): Color3;
  3716. /**
  3717. * Converts current color in rgb space to HSV values
  3718. * @returns a new color3 representing the HSV values
  3719. */
  3720. toHSV(): Color3;
  3721. /**
  3722. * Converts current color in rgb space to HSV values
  3723. * @param result defines the Color3 where to store the HSV values
  3724. */
  3725. toHSVToRef(result: Color3): void;
  3726. /**
  3727. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  3728. * @param convertedColor defines the Color3 object where to store the linear space version
  3729. * @returns the unmodified Color3
  3730. */
  3731. toLinearSpaceToRef(convertedColor: Color3): Color3;
  3732. /**
  3733. * Computes a new Color3 converted from the current one to gamma space
  3734. * @returns a new Color3 object
  3735. */
  3736. toGammaSpace(): Color3;
  3737. /**
  3738. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  3739. * @param convertedColor defines the Color3 object where to store the gamma space version
  3740. * @returns the unmodified Color3
  3741. */
  3742. toGammaSpaceToRef(convertedColor: Color3): Color3;
  3743. private static _BlackReadOnly;
  3744. /**
  3745. * Convert Hue, saturation and value to a Color3 (RGB)
  3746. * @param hue defines the hue
  3747. * @param saturation defines the saturation
  3748. * @param value defines the value
  3749. * @param result defines the Color3 where to store the RGB values
  3750. */
  3751. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  3752. /**
  3753. * Creates a new Color3 from the string containing valid hexadecimal values
  3754. * @param hex defines a string containing valid hexadecimal values
  3755. * @returns a new Color3 object
  3756. */
  3757. static FromHexString(hex: string): Color3;
  3758. /**
  3759. * Creates a new Color3 from the starting index of the given array
  3760. * @param array defines the source array
  3761. * @param offset defines an offset in the source array
  3762. * @returns a new Color3 object
  3763. */
  3764. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  3765. /**
  3766. * Creates a new Color3 from integer values (< 256)
  3767. * @param r defines the red component to read from (value between 0 and 255)
  3768. * @param g defines the green component to read from (value between 0 and 255)
  3769. * @param b defines the blue component to read from (value between 0 and 255)
  3770. * @returns a new Color3 object
  3771. */
  3772. static FromInts(r: number, g: number, b: number): Color3;
  3773. /**
  3774. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3775. * @param start defines the start Color3 value
  3776. * @param end defines the end Color3 value
  3777. * @param amount defines the gradient value between start and end
  3778. * @returns a new Color3 object
  3779. */
  3780. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  3781. /**
  3782. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3783. * @param left defines the start value
  3784. * @param right defines the end value
  3785. * @param amount defines the gradient factor
  3786. * @param result defines the Color3 object where to store the result
  3787. */
  3788. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  3789. /**
  3790. * Returns a Color3 value containing a red color
  3791. * @returns a new Color3 object
  3792. */
  3793. static Red(): Color3;
  3794. /**
  3795. * Returns a Color3 value containing a green color
  3796. * @returns a new Color3 object
  3797. */
  3798. static Green(): Color3;
  3799. /**
  3800. * Returns a Color3 value containing a blue color
  3801. * @returns a new Color3 object
  3802. */
  3803. static Blue(): Color3;
  3804. /**
  3805. * Returns a Color3 value containing a black color
  3806. * @returns a new Color3 object
  3807. */
  3808. static Black(): Color3;
  3809. /**
  3810. * Gets a Color3 value containing a black color that must not be updated
  3811. */
  3812. static readonly BlackReadOnly: DeepImmutable<Color3>;
  3813. /**
  3814. * Returns a Color3 value containing a white color
  3815. * @returns a new Color3 object
  3816. */
  3817. static White(): Color3;
  3818. /**
  3819. * Returns a Color3 value containing a purple color
  3820. * @returns a new Color3 object
  3821. */
  3822. static Purple(): Color3;
  3823. /**
  3824. * Returns a Color3 value containing a magenta color
  3825. * @returns a new Color3 object
  3826. */
  3827. static Magenta(): Color3;
  3828. /**
  3829. * Returns a Color3 value containing a yellow color
  3830. * @returns a new Color3 object
  3831. */
  3832. static Yellow(): Color3;
  3833. /**
  3834. * Returns a Color3 value containing a gray color
  3835. * @returns a new Color3 object
  3836. */
  3837. static Gray(): Color3;
  3838. /**
  3839. * Returns a Color3 value containing a teal color
  3840. * @returns a new Color3 object
  3841. */
  3842. static Teal(): Color3;
  3843. /**
  3844. * Returns a Color3 value containing a random color
  3845. * @returns a new Color3 object
  3846. */
  3847. static Random(): Color3;
  3848. }
  3849. /**
  3850. * Class used to hold a RBGA color
  3851. */
  3852. export class Color4 {
  3853. /**
  3854. * Defines the red component (between 0 and 1, default is 0)
  3855. */
  3856. r: number;
  3857. /**
  3858. * Defines the green component (between 0 and 1, default is 0)
  3859. */
  3860. g: number;
  3861. /**
  3862. * Defines the blue component (between 0 and 1, default is 0)
  3863. */
  3864. b: number;
  3865. /**
  3866. * Defines the alpha component (between 0 and 1, default is 1)
  3867. */
  3868. a: number;
  3869. /**
  3870. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  3871. * @param r defines the red component (between 0 and 1, default is 0)
  3872. * @param g defines the green component (between 0 and 1, default is 0)
  3873. * @param b defines the blue component (between 0 and 1, default is 0)
  3874. * @param a defines the alpha component (between 0 and 1, default is 1)
  3875. */
  3876. constructor(
  3877. /**
  3878. * Defines the red component (between 0 and 1, default is 0)
  3879. */
  3880. r?: number,
  3881. /**
  3882. * Defines the green component (between 0 and 1, default is 0)
  3883. */
  3884. g?: number,
  3885. /**
  3886. * Defines the blue component (between 0 and 1, default is 0)
  3887. */
  3888. b?: number,
  3889. /**
  3890. * Defines the alpha component (between 0 and 1, default is 1)
  3891. */
  3892. a?: number);
  3893. /**
  3894. * Adds in place the given Color4 values to the current Color4 object
  3895. * @param right defines the second operand
  3896. * @returns the current updated Color4 object
  3897. */
  3898. addInPlace(right: DeepImmutable<Color4>): Color4;
  3899. /**
  3900. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  3901. * @returns the new array
  3902. */
  3903. asArray(): number[];
  3904. /**
  3905. * Stores from the starting index in the given array the Color4 successive values
  3906. * @param array defines the array where to store the r,g,b components
  3907. * @param index defines an optional index in the target array to define where to start storing values
  3908. * @returns the current Color4 object
  3909. */
  3910. toArray(array: number[], index?: number): Color4;
  3911. /**
  3912. * Determines equality between Color4 objects
  3913. * @param otherColor defines the second operand
  3914. * @returns true if the rgba values are equal to the given ones
  3915. */
  3916. equals(otherColor: DeepImmutable<Color4>): boolean;
  3917. /**
  3918. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  3919. * @param right defines the second operand
  3920. * @returns a new Color4 object
  3921. */
  3922. add(right: DeepImmutable<Color4>): Color4;
  3923. /**
  3924. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  3925. * @param right defines the second operand
  3926. * @returns a new Color4 object
  3927. */
  3928. subtract(right: DeepImmutable<Color4>): Color4;
  3929. /**
  3930. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  3931. * @param right defines the second operand
  3932. * @param result defines the Color4 object where to store the result
  3933. * @returns the current Color4 object
  3934. */
  3935. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  3936. /**
  3937. * Creates a new Color4 with the current Color4 values multiplied by scale
  3938. * @param scale defines the scaling factor to apply
  3939. * @returns a new Color4 object
  3940. */
  3941. scale(scale: number): Color4;
  3942. /**
  3943. * Multiplies the current Color4 values by scale and stores the result in "result"
  3944. * @param scale defines the scaling factor to apply
  3945. * @param result defines the Color4 object where to store the result
  3946. * @returns the current unmodified Color4
  3947. */
  3948. scaleToRef(scale: number, result: Color4): Color4;
  3949. /**
  3950. * Scale the current Color4 values by a factor and add the result to a given Color4
  3951. * @param scale defines the scale factor
  3952. * @param result defines the Color4 object where to store the result
  3953. * @returns the unmodified current Color4
  3954. */
  3955. scaleAndAddToRef(scale: number, result: Color4): Color4;
  3956. /**
  3957. * Clamps the rgb values by the min and max values and stores the result into "result"
  3958. * @param min defines minimum clamping value (default is 0)
  3959. * @param max defines maximum clamping value (default is 1)
  3960. * @param result defines color to store the result into.
  3961. * @returns the cuurent Color4
  3962. */
  3963. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  3964. /**
  3965. * Multipy an Color4 value by another and return a new Color4 object
  3966. * @param color defines the Color4 value to multiply by
  3967. * @returns a new Color4 object
  3968. */
  3969. multiply(color: Color4): Color4;
  3970. /**
  3971. * Multipy a Color4 value by another and push the result in a reference value
  3972. * @param color defines the Color4 value to multiply by
  3973. * @param result defines the Color4 to fill the result in
  3974. * @returns the result Color4
  3975. */
  3976. multiplyToRef(color: Color4, result: Color4): Color4;
  3977. /**
  3978. * Creates a string with the Color4 current values
  3979. * @returns the string representation of the Color4 object
  3980. */
  3981. toString(): string;
  3982. /**
  3983. * Returns the string "Color4"
  3984. * @returns "Color4"
  3985. */
  3986. getClassName(): string;
  3987. /**
  3988. * Compute the Color4 hash code
  3989. * @returns an unique number that can be used to hash Color4 objects
  3990. */
  3991. getHashCode(): number;
  3992. /**
  3993. * Creates a new Color4 copied from the current one
  3994. * @returns a new Color4 object
  3995. */
  3996. clone(): Color4;
  3997. /**
  3998. * Copies the given Color4 values into the current one
  3999. * @param source defines the source Color4 object
  4000. * @returns the current updated Color4 object
  4001. */
  4002. copyFrom(source: Color4): Color4;
  4003. /**
  4004. * Copies the given float values into the current one
  4005. * @param r defines the red component to read from
  4006. * @param g defines the green component to read from
  4007. * @param b defines the blue component to read from
  4008. * @param a defines the alpha component to read from
  4009. * @returns the current updated Color4 object
  4010. */
  4011. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  4012. /**
  4013. * Copies the given float values into the current one
  4014. * @param r defines the red component to read from
  4015. * @param g defines the green component to read from
  4016. * @param b defines the blue component to read from
  4017. * @param a defines the alpha component to read from
  4018. * @returns the current updated Color4 object
  4019. */
  4020. set(r: number, g: number, b: number, a: number): Color4;
  4021. /**
  4022. * Compute the Color4 hexadecimal code as a string
  4023. * @returns a string containing the hexadecimal representation of the Color4 object
  4024. */
  4025. toHexString(): string;
  4026. /**
  4027. * Computes a new Color4 converted from the current one to linear space
  4028. * @returns a new Color4 object
  4029. */
  4030. toLinearSpace(): Color4;
  4031. /**
  4032. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  4033. * @param convertedColor defines the Color4 object where to store the linear space version
  4034. * @returns the unmodified Color4
  4035. */
  4036. toLinearSpaceToRef(convertedColor: Color4): Color4;
  4037. /**
  4038. * Computes a new Color4 converted from the current one to gamma space
  4039. * @returns a new Color4 object
  4040. */
  4041. toGammaSpace(): Color4;
  4042. /**
  4043. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  4044. * @param convertedColor defines the Color4 object where to store the gamma space version
  4045. * @returns the unmodified Color4
  4046. */
  4047. toGammaSpaceToRef(convertedColor: Color4): Color4;
  4048. /**
  4049. * Creates a new Color4 from the string containing valid hexadecimal values
  4050. * @param hex defines a string containing valid hexadecimal values
  4051. * @returns a new Color4 object
  4052. */
  4053. static FromHexString(hex: string): Color4;
  4054. /**
  4055. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4056. * @param left defines the start value
  4057. * @param right defines the end value
  4058. * @param amount defines the gradient factor
  4059. * @returns a new Color4 object
  4060. */
  4061. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  4062. /**
  4063. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4064. * @param left defines the start value
  4065. * @param right defines the end value
  4066. * @param amount defines the gradient factor
  4067. * @param result defines the Color4 object where to store data
  4068. */
  4069. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  4070. /**
  4071. * Creates a new Color4 from a Color3 and an alpha value
  4072. * @param color3 defines the source Color3 to read from
  4073. * @param alpha defines the alpha component (1.0 by default)
  4074. * @returns a new Color4 object
  4075. */
  4076. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  4077. /**
  4078. * Creates a new Color4 from the starting index element of the given array
  4079. * @param array defines the source array to read from
  4080. * @param offset defines the offset in the source array
  4081. * @returns a new Color4 object
  4082. */
  4083. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  4084. /**
  4085. * Creates a new Color3 from integer values (< 256)
  4086. * @param r defines the red component to read from (value between 0 and 255)
  4087. * @param g defines the green component to read from (value between 0 and 255)
  4088. * @param b defines the blue component to read from (value between 0 and 255)
  4089. * @param a defines the alpha component to read from (value between 0 and 255)
  4090. * @returns a new Color3 object
  4091. */
  4092. static FromInts(r: number, g: number, b: number, a: number): Color4;
  4093. /**
  4094. * Check the content of a given array and convert it to an array containing RGBA data
  4095. * If the original array was already containing count * 4 values then it is returned directly
  4096. * @param colors defines the array to check
  4097. * @param count defines the number of RGBA data to expect
  4098. * @returns an array containing count * 4 values (RGBA)
  4099. */
  4100. static CheckColors4(colors: number[], count: number): number[];
  4101. }
  4102. /**
  4103. * @hidden
  4104. */
  4105. export class TmpColors {
  4106. static Color3: Color3[];
  4107. static Color4: Color4[];
  4108. }
  4109. }
  4110. declare module BABYLON {
  4111. /**
  4112. * Class representing spherical harmonics coefficients to the 3rd degree
  4113. */
  4114. export class SphericalHarmonics {
  4115. /**
  4116. * Defines whether or not the harmonics have been prescaled for rendering.
  4117. */
  4118. preScaled: boolean;
  4119. /**
  4120. * The l0,0 coefficients of the spherical harmonics
  4121. */
  4122. l00: Vector3;
  4123. /**
  4124. * The l1,-1 coefficients of the spherical harmonics
  4125. */
  4126. l1_1: Vector3;
  4127. /**
  4128. * The l1,0 coefficients of the spherical harmonics
  4129. */
  4130. l10: Vector3;
  4131. /**
  4132. * The l1,1 coefficients of the spherical harmonics
  4133. */
  4134. l11: Vector3;
  4135. /**
  4136. * The l2,-2 coefficients of the spherical harmonics
  4137. */
  4138. l2_2: Vector3;
  4139. /**
  4140. * The l2,-1 coefficients of the spherical harmonics
  4141. */
  4142. l2_1: Vector3;
  4143. /**
  4144. * The l2,0 coefficients of the spherical harmonics
  4145. */
  4146. l20: Vector3;
  4147. /**
  4148. * The l2,1 coefficients of the spherical harmonics
  4149. */
  4150. l21: Vector3;
  4151. /**
  4152. * The l2,2 coefficients of the spherical harmonics
  4153. */
  4154. l22: Vector3;
  4155. /**
  4156. * Adds a light to the spherical harmonics
  4157. * @param direction the direction of the light
  4158. * @param color the color of the light
  4159. * @param deltaSolidAngle the delta solid angle of the light
  4160. */
  4161. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  4162. /**
  4163. * Scales the spherical harmonics by the given amount
  4164. * @param scale the amount to scale
  4165. */
  4166. scaleInPlace(scale: number): void;
  4167. /**
  4168. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  4169. *
  4170. * ```
  4171. * E_lm = A_l * L_lm
  4172. * ```
  4173. *
  4174. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  4175. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  4176. * the scaling factors are given in equation 9.
  4177. */
  4178. convertIncidentRadianceToIrradiance(): void;
  4179. /**
  4180. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  4181. *
  4182. * ```
  4183. * L = (1/pi) * E * rho
  4184. * ```
  4185. *
  4186. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  4187. */
  4188. convertIrradianceToLambertianRadiance(): void;
  4189. /**
  4190. * Integrates the reconstruction coefficients directly in to the SH preventing further
  4191. * required operations at run time.
  4192. *
  4193. * This is simply done by scaling back the SH with Ylm constants parameter.
  4194. * The trigonometric part being applied by the shader at run time.
  4195. */
  4196. preScaleForRendering(): void;
  4197. /**
  4198. * Constructs a spherical harmonics from an array.
  4199. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  4200. * @returns the spherical harmonics
  4201. */
  4202. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  4203. /**
  4204. * Gets the spherical harmonics from polynomial
  4205. * @param polynomial the spherical polynomial
  4206. * @returns the spherical harmonics
  4207. */
  4208. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  4209. }
  4210. /**
  4211. * Class representing spherical polynomial coefficients to the 3rd degree
  4212. */
  4213. export class SphericalPolynomial {
  4214. private _harmonics;
  4215. /**
  4216. * The spherical harmonics used to create the polynomials.
  4217. */
  4218. readonly preScaledHarmonics: SphericalHarmonics;
  4219. /**
  4220. * The x coefficients of the spherical polynomial
  4221. */
  4222. x: Vector3;
  4223. /**
  4224. * The y coefficients of the spherical polynomial
  4225. */
  4226. y: Vector3;
  4227. /**
  4228. * The z coefficients of the spherical polynomial
  4229. */
  4230. z: Vector3;
  4231. /**
  4232. * The xx coefficients of the spherical polynomial
  4233. */
  4234. xx: Vector3;
  4235. /**
  4236. * The yy coefficients of the spherical polynomial
  4237. */
  4238. yy: Vector3;
  4239. /**
  4240. * The zz coefficients of the spherical polynomial
  4241. */
  4242. zz: Vector3;
  4243. /**
  4244. * The xy coefficients of the spherical polynomial
  4245. */
  4246. xy: Vector3;
  4247. /**
  4248. * The yz coefficients of the spherical polynomial
  4249. */
  4250. yz: Vector3;
  4251. /**
  4252. * The zx coefficients of the spherical polynomial
  4253. */
  4254. zx: Vector3;
  4255. /**
  4256. * Adds an ambient color to the spherical polynomial
  4257. * @param color the color to add
  4258. */
  4259. addAmbient(color: Color3): void;
  4260. /**
  4261. * Scales the spherical polynomial by the given amount
  4262. * @param scale the amount to scale
  4263. */
  4264. scaleInPlace(scale: number): void;
  4265. /**
  4266. * Gets the spherical polynomial from harmonics
  4267. * @param harmonics the spherical harmonics
  4268. * @returns the spherical polynomial
  4269. */
  4270. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  4271. /**
  4272. * Constructs a spherical polynomial from an array.
  4273. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  4274. * @returns the spherical polynomial
  4275. */
  4276. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  4277. }
  4278. }
  4279. declare module BABYLON {
  4280. /**
  4281. * Define options used to create a render target texture
  4282. */
  4283. export class RenderTargetCreationOptions {
  4284. /**
  4285. * Specifies is mipmaps must be generated
  4286. */
  4287. generateMipMaps?: boolean;
  4288. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4289. generateDepthBuffer?: boolean;
  4290. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4291. generateStencilBuffer?: boolean;
  4292. /** Defines texture type (int by default) */
  4293. type?: number;
  4294. /** Defines sampling mode (trilinear by default) */
  4295. samplingMode?: number;
  4296. /** Defines format (RGBA by default) */
  4297. format?: number;
  4298. }
  4299. }
  4300. declare module BABYLON {
  4301. /**
  4302. * @hidden
  4303. **/
  4304. export class _TimeToken {
  4305. _startTimeQuery: Nullable<WebGLQuery>;
  4306. _endTimeQuery: Nullable<WebGLQuery>;
  4307. _timeElapsedQuery: Nullable<WebGLQuery>;
  4308. _timeElapsedQueryEnded: boolean;
  4309. }
  4310. }
  4311. declare module BABYLON {
  4312. /** Defines the cross module used constants to avoid circular dependncies */
  4313. export class Constants {
  4314. /** Defines that alpha blending is disabled */
  4315. static readonly ALPHA_DISABLE: number;
  4316. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4317. static readonly ALPHA_ADD: number;
  4318. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4319. static readonly ALPHA_COMBINE: number;
  4320. /** Defines that alpha blending to DEST - SRC * DEST */
  4321. static readonly ALPHA_SUBTRACT: number;
  4322. /** Defines that alpha blending to SRC * DEST */
  4323. static readonly ALPHA_MULTIPLY: number;
  4324. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4325. static readonly ALPHA_MAXIMIZED: number;
  4326. /** Defines that alpha blending to SRC + DEST */
  4327. static readonly ALPHA_ONEONE: number;
  4328. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4329. static readonly ALPHA_PREMULTIPLIED: number;
  4330. /**
  4331. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4332. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4333. */
  4334. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4335. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4336. static readonly ALPHA_INTERPOLATE: number;
  4337. /**
  4338. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4339. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4340. */
  4341. static readonly ALPHA_SCREENMODE: number;
  4342. /**
  4343. * Defines that alpha blending to SRC + DST
  4344. * Alpha will be set to SRC ALPHA + DST ALPHA
  4345. */
  4346. static readonly ALPHA_ONEONE_ONEONE: number;
  4347. /**
  4348. * Defines that alpha blending to SRC * DST ALPHA + DST
  4349. * Alpha will be set to 0
  4350. */
  4351. static readonly ALPHA_ALPHATOCOLOR: number;
  4352. /**
  4353. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4354. */
  4355. static readonly ALPHA_REVERSEONEMINUS: number;
  4356. /**
  4357. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4358. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4359. */
  4360. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4361. /**
  4362. * Defines that alpha blending to SRC + DST
  4363. * Alpha will be set to SRC ALPHA
  4364. */
  4365. static readonly ALPHA_ONEONE_ONEZERO: number;
  4366. /** Defines that alpha blending equation a SUM */
  4367. static readonly ALPHA_EQUATION_ADD: number;
  4368. /** Defines that alpha blending equation a SUBSTRACTION */
  4369. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4370. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4371. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4372. /** Defines that alpha blending equation a MAX operation */
  4373. static readonly ALPHA_EQUATION_MAX: number;
  4374. /** Defines that alpha blending equation a MIN operation */
  4375. static readonly ALPHA_EQUATION_MIN: number;
  4376. /**
  4377. * Defines that alpha blending equation a DARKEN operation:
  4378. * It takes the min of the src and sums the alpha channels.
  4379. */
  4380. static readonly ALPHA_EQUATION_DARKEN: number;
  4381. /** Defines that the ressource is not delayed*/
  4382. static readonly DELAYLOADSTATE_NONE: number;
  4383. /** Defines that the ressource was successfully delay loaded */
  4384. static readonly DELAYLOADSTATE_LOADED: number;
  4385. /** Defines that the ressource is currently delay loading */
  4386. static readonly DELAYLOADSTATE_LOADING: number;
  4387. /** Defines that the ressource is delayed and has not started loading */
  4388. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4389. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4390. static readonly NEVER: number;
  4391. /** 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 */
  4392. static readonly ALWAYS: number;
  4393. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4394. static readonly LESS: number;
  4395. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4396. static readonly EQUAL: number;
  4397. /** 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 */
  4398. static readonly LEQUAL: number;
  4399. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4400. static readonly GREATER: number;
  4401. /** 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 */
  4402. static readonly GEQUAL: number;
  4403. /** 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 */
  4404. static readonly NOTEQUAL: number;
  4405. /** Passed to stencilOperation to specify that stencil value must be kept */
  4406. static readonly KEEP: number;
  4407. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4408. static readonly REPLACE: number;
  4409. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4410. static readonly INCR: number;
  4411. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4412. static readonly DECR: number;
  4413. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4414. static readonly INVERT: number;
  4415. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4416. static readonly INCR_WRAP: number;
  4417. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4418. static readonly DECR_WRAP: number;
  4419. /** Texture is not repeating outside of 0..1 UVs */
  4420. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4421. /** Texture is repeating outside of 0..1 UVs */
  4422. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4423. /** Texture is repeating and mirrored */
  4424. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4425. /** ALPHA */
  4426. static readonly TEXTUREFORMAT_ALPHA: number;
  4427. /** LUMINANCE */
  4428. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4429. /** LUMINANCE_ALPHA */
  4430. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4431. /** RGB */
  4432. static readonly TEXTUREFORMAT_RGB: number;
  4433. /** RGBA */
  4434. static readonly TEXTUREFORMAT_RGBA: number;
  4435. /** RED */
  4436. static readonly TEXTUREFORMAT_RED: number;
  4437. /** RED (2nd reference) */
  4438. static readonly TEXTUREFORMAT_R: number;
  4439. /** RG */
  4440. static readonly TEXTUREFORMAT_RG: number;
  4441. /** RED_INTEGER */
  4442. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4443. /** RED_INTEGER (2nd reference) */
  4444. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4445. /** RG_INTEGER */
  4446. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4447. /** RGB_INTEGER */
  4448. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4449. /** RGBA_INTEGER */
  4450. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4451. /** UNSIGNED_BYTE */
  4452. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4453. /** UNSIGNED_BYTE (2nd reference) */
  4454. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4455. /** FLOAT */
  4456. static readonly TEXTURETYPE_FLOAT: number;
  4457. /** HALF_FLOAT */
  4458. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4459. /** BYTE */
  4460. static readonly TEXTURETYPE_BYTE: number;
  4461. /** SHORT */
  4462. static readonly TEXTURETYPE_SHORT: number;
  4463. /** UNSIGNED_SHORT */
  4464. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4465. /** INT */
  4466. static readonly TEXTURETYPE_INT: number;
  4467. /** UNSIGNED_INT */
  4468. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4469. /** UNSIGNED_SHORT_4_4_4_4 */
  4470. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4471. /** UNSIGNED_SHORT_5_5_5_1 */
  4472. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4473. /** UNSIGNED_SHORT_5_6_5 */
  4474. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4475. /** UNSIGNED_INT_2_10_10_10_REV */
  4476. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4477. /** UNSIGNED_INT_24_8 */
  4478. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4479. /** UNSIGNED_INT_10F_11F_11F_REV */
  4480. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4481. /** UNSIGNED_INT_5_9_9_9_REV */
  4482. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4483. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4484. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4485. /** nearest is mag = nearest and min = nearest and mip = linear */
  4486. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4487. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4488. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4489. /** Trilinear is mag = linear and min = linear and mip = linear */
  4490. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4491. /** nearest is mag = nearest and min = nearest and mip = linear */
  4492. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4493. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4494. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4495. /** Trilinear is mag = linear and min = linear and mip = linear */
  4496. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4497. /** mag = nearest and min = nearest and mip = nearest */
  4498. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4499. /** mag = nearest and min = linear and mip = nearest */
  4500. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4501. /** mag = nearest and min = linear and mip = linear */
  4502. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4503. /** mag = nearest and min = linear and mip = none */
  4504. static readonly TEXTURE_NEAREST_LINEAR: number;
  4505. /** mag = nearest and min = nearest and mip = none */
  4506. static readonly TEXTURE_NEAREST_NEAREST: number;
  4507. /** mag = linear and min = nearest and mip = nearest */
  4508. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4509. /** mag = linear and min = nearest and mip = linear */
  4510. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4511. /** mag = linear and min = linear and mip = none */
  4512. static readonly TEXTURE_LINEAR_LINEAR: number;
  4513. /** mag = linear and min = nearest and mip = none */
  4514. static readonly TEXTURE_LINEAR_NEAREST: number;
  4515. /** Explicit coordinates mode */
  4516. static readonly TEXTURE_EXPLICIT_MODE: number;
  4517. /** Spherical coordinates mode */
  4518. static readonly TEXTURE_SPHERICAL_MODE: number;
  4519. /** Planar coordinates mode */
  4520. static readonly TEXTURE_PLANAR_MODE: number;
  4521. /** Cubic coordinates mode */
  4522. static readonly TEXTURE_CUBIC_MODE: number;
  4523. /** Projection coordinates mode */
  4524. static readonly TEXTURE_PROJECTION_MODE: number;
  4525. /** Skybox coordinates mode */
  4526. static readonly TEXTURE_SKYBOX_MODE: number;
  4527. /** Inverse Cubic coordinates mode */
  4528. static readonly TEXTURE_INVCUBIC_MODE: number;
  4529. /** Equirectangular coordinates mode */
  4530. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4531. /** Equirectangular Fixed coordinates mode */
  4532. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4533. /** Equirectangular Fixed Mirrored coordinates mode */
  4534. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4535. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4536. static readonly SCALEMODE_FLOOR: number;
  4537. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4538. static readonly SCALEMODE_NEAREST: number;
  4539. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4540. static readonly SCALEMODE_CEILING: number;
  4541. /**
  4542. * The dirty texture flag value
  4543. */
  4544. static readonly MATERIAL_TextureDirtyFlag: number;
  4545. /**
  4546. * The dirty light flag value
  4547. */
  4548. static readonly MATERIAL_LightDirtyFlag: number;
  4549. /**
  4550. * The dirty fresnel flag value
  4551. */
  4552. static readonly MATERIAL_FresnelDirtyFlag: number;
  4553. /**
  4554. * The dirty attribute flag value
  4555. */
  4556. static readonly MATERIAL_AttributesDirtyFlag: number;
  4557. /**
  4558. * The dirty misc flag value
  4559. */
  4560. static readonly MATERIAL_MiscDirtyFlag: number;
  4561. /**
  4562. * The all dirty flag value
  4563. */
  4564. static readonly MATERIAL_AllDirtyFlag: number;
  4565. /**
  4566. * Returns the triangle fill mode
  4567. */
  4568. static readonly MATERIAL_TriangleFillMode: number;
  4569. /**
  4570. * Returns the wireframe mode
  4571. */
  4572. static readonly MATERIAL_WireFrameFillMode: number;
  4573. /**
  4574. * Returns the point fill mode
  4575. */
  4576. static readonly MATERIAL_PointFillMode: number;
  4577. /**
  4578. * Returns the point list draw mode
  4579. */
  4580. static readonly MATERIAL_PointListDrawMode: number;
  4581. /**
  4582. * Returns the line list draw mode
  4583. */
  4584. static readonly MATERIAL_LineListDrawMode: number;
  4585. /**
  4586. * Returns the line loop draw mode
  4587. */
  4588. static readonly MATERIAL_LineLoopDrawMode: number;
  4589. /**
  4590. * Returns the line strip draw mode
  4591. */
  4592. static readonly MATERIAL_LineStripDrawMode: number;
  4593. /**
  4594. * Returns the triangle strip draw mode
  4595. */
  4596. static readonly MATERIAL_TriangleStripDrawMode: number;
  4597. /**
  4598. * Returns the triangle fan draw mode
  4599. */
  4600. static readonly MATERIAL_TriangleFanDrawMode: number;
  4601. /**
  4602. * Stores the clock-wise side orientation
  4603. */
  4604. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4605. /**
  4606. * Stores the counter clock-wise side orientation
  4607. */
  4608. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4609. /**
  4610. * Nothing
  4611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4612. */
  4613. static readonly ACTION_NothingTrigger: number;
  4614. /**
  4615. * On pick
  4616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4617. */
  4618. static readonly ACTION_OnPickTrigger: number;
  4619. /**
  4620. * On left pick
  4621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4622. */
  4623. static readonly ACTION_OnLeftPickTrigger: number;
  4624. /**
  4625. * On right pick
  4626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4627. */
  4628. static readonly ACTION_OnRightPickTrigger: number;
  4629. /**
  4630. * On center pick
  4631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4632. */
  4633. static readonly ACTION_OnCenterPickTrigger: number;
  4634. /**
  4635. * On pick down
  4636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4637. */
  4638. static readonly ACTION_OnPickDownTrigger: number;
  4639. /**
  4640. * On double pick
  4641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4642. */
  4643. static readonly ACTION_OnDoublePickTrigger: number;
  4644. /**
  4645. * On pick up
  4646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4647. */
  4648. static readonly ACTION_OnPickUpTrigger: number;
  4649. /**
  4650. * On pick out.
  4651. * This trigger will only be raised if you also declared a OnPickDown
  4652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4653. */
  4654. static readonly ACTION_OnPickOutTrigger: number;
  4655. /**
  4656. * On long press
  4657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4658. */
  4659. static readonly ACTION_OnLongPressTrigger: number;
  4660. /**
  4661. * On pointer over
  4662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4663. */
  4664. static readonly ACTION_OnPointerOverTrigger: number;
  4665. /**
  4666. * On pointer out
  4667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4668. */
  4669. static readonly ACTION_OnPointerOutTrigger: number;
  4670. /**
  4671. * On every frame
  4672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4673. */
  4674. static readonly ACTION_OnEveryFrameTrigger: number;
  4675. /**
  4676. * On intersection enter
  4677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4678. */
  4679. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4680. /**
  4681. * On intersection exit
  4682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4683. */
  4684. static readonly ACTION_OnIntersectionExitTrigger: number;
  4685. /**
  4686. * On key down
  4687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4688. */
  4689. static readonly ACTION_OnKeyDownTrigger: number;
  4690. /**
  4691. * On key up
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_OnKeyUpTrigger: number;
  4695. /**
  4696. * Billboard mode will only apply to Y axis
  4697. */
  4698. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4699. /**
  4700. * Billboard mode will apply to all axes
  4701. */
  4702. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4703. /**
  4704. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4705. */
  4706. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4707. /**
  4708. * Gets or sets base Assets URL
  4709. */
  4710. static PARTICLES_BaseAssetsUrl: string;
  4711. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4712. * Test order :
  4713. * Is the bounding sphere outside the frustum ?
  4714. * If not, are the bounding box vertices outside the frustum ?
  4715. * It not, then the cullable object is in the frustum.
  4716. */
  4717. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4718. /** Culling strategy : Bounding Sphere Only.
  4719. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4720. * It's also less accurate than the standard because some not visible objects can still be selected.
  4721. * Test : is the bounding sphere outside the frustum ?
  4722. * If not, then the cullable object is in the frustum.
  4723. */
  4724. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4725. /** Culling strategy : Optimistic Inclusion.
  4726. * This in an inclusion test first, then the standard exclusion test.
  4727. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4728. * 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.
  4729. * Anyway, it's as accurate as the standard strategy.
  4730. * Test :
  4731. * Is the cullable object bounding sphere center in the frustum ?
  4732. * If not, apply the default culling strategy.
  4733. */
  4734. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4735. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4736. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4737. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4738. * 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.
  4739. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4740. * Test :
  4741. * Is the cullable object bounding sphere center in the frustum ?
  4742. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4743. */
  4744. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4745. /**
  4746. * No logging while loading
  4747. */
  4748. static readonly SCENELOADER_NO_LOGGING: number;
  4749. /**
  4750. * Minimal logging while loading
  4751. */
  4752. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4753. /**
  4754. * Summary logging while loading
  4755. */
  4756. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4757. /**
  4758. * Detailled logging while loading
  4759. */
  4760. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4761. }
  4762. }
  4763. declare module BABYLON {
  4764. /**
  4765. * This represents the required contract to create a new type of texture loader.
  4766. */
  4767. export interface IInternalTextureLoader {
  4768. /**
  4769. * Defines wether the loader supports cascade loading the different faces.
  4770. */
  4771. supportCascades: boolean;
  4772. /**
  4773. * This returns if the loader support the current file information.
  4774. * @param extension defines the file extension of the file being loaded
  4775. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4776. * @param fallback defines the fallback internal texture if any
  4777. * @param isBase64 defines whether the texture is encoded as a base64
  4778. * @param isBuffer defines whether the texture data are stored as a buffer
  4779. * @returns true if the loader can load the specified file
  4780. */
  4781. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  4782. /**
  4783. * Transform the url before loading if required.
  4784. * @param rootUrl the url of the texture
  4785. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4786. * @returns the transformed texture
  4787. */
  4788. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  4789. /**
  4790. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  4791. * @param rootUrl the url of the texture
  4792. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4793. * @returns the fallback texture
  4794. */
  4795. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  4796. /**
  4797. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  4798. * @param data contains the texture data
  4799. * @param texture defines the BabylonJS internal texture
  4800. * @param createPolynomials will be true if polynomials have been requested
  4801. * @param onLoad defines the callback to trigger once the texture is ready
  4802. * @param onError defines the callback to trigger in case of error
  4803. */
  4804. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  4805. /**
  4806. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  4807. * @param data contains the texture data
  4808. * @param texture defines the BabylonJS internal texture
  4809. * @param callback defines the method to call once ready to upload
  4810. */
  4811. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  4812. }
  4813. }
  4814. declare module BABYLON {
  4815. /**
  4816. * Class used to store and describe the pipeline context associated with an effect
  4817. */
  4818. export interface IPipelineContext {
  4819. /**
  4820. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4821. */
  4822. isAsync: boolean;
  4823. /**
  4824. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4825. */
  4826. isReady: boolean;
  4827. /** @hidden */
  4828. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4829. }
  4830. }
  4831. declare module BABYLON {
  4832. /**
  4833. * Class used to store gfx data (like WebGLBuffer)
  4834. */
  4835. export class DataBuffer {
  4836. /**
  4837. * Gets or sets the number of objects referencing this buffer
  4838. */
  4839. references: number;
  4840. /** Gets or sets the size of the underlying buffer */
  4841. capacity: number;
  4842. /**
  4843. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  4844. */
  4845. is32Bits: boolean;
  4846. /**
  4847. * Gets the underlying buffer
  4848. */
  4849. readonly underlyingResource: any;
  4850. }
  4851. }
  4852. declare module BABYLON {
  4853. /** @hidden */
  4854. export interface IShaderProcessor {
  4855. attributeProcessor?: (attribute: string) => string;
  4856. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4857. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4858. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4859. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4860. lineProcessor?: (line: string, isFragment: boolean) => string;
  4861. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4862. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4863. }
  4864. }
  4865. declare module BABYLON {
  4866. /** @hidden */
  4867. export interface ProcessingOptions {
  4868. defines: string[];
  4869. indexParameters: any;
  4870. isFragment: boolean;
  4871. shouldUseHighPrecisionShader: boolean;
  4872. supportsUniformBuffers: boolean;
  4873. shadersRepository: string;
  4874. includesShadersStore: {
  4875. [key: string]: string;
  4876. };
  4877. processor?: IShaderProcessor;
  4878. version: string;
  4879. platformName: string;
  4880. lookForClosingBracketForUniformBuffer?: boolean;
  4881. }
  4882. }
  4883. declare module BABYLON {
  4884. /**
  4885. * Helper to manipulate strings
  4886. */
  4887. export class StringTools {
  4888. /**
  4889. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4890. * @param str Source string
  4891. * @param suffix Suffix to search for in the source string
  4892. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4893. */
  4894. static EndsWith(str: string, suffix: string): boolean;
  4895. /**
  4896. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4897. * @param str Source string
  4898. * @param suffix Suffix to search for in the source string
  4899. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4900. */
  4901. static StartsWith(str: string, suffix: string): boolean;
  4902. }
  4903. }
  4904. declare module BABYLON {
  4905. /** @hidden */
  4906. export class ShaderCodeNode {
  4907. line: string;
  4908. children: ShaderCodeNode[];
  4909. additionalDefineKey?: string;
  4910. additionalDefineValue?: string;
  4911. isValid(preprocessors: {
  4912. [key: string]: string;
  4913. }): boolean;
  4914. process(preprocessors: {
  4915. [key: string]: string;
  4916. }, options: ProcessingOptions): string;
  4917. }
  4918. }
  4919. declare module BABYLON {
  4920. /** @hidden */
  4921. export class ShaderCodeCursor {
  4922. private _lines;
  4923. lineIndex: number;
  4924. readonly currentLine: string;
  4925. readonly canRead: boolean;
  4926. lines: string[];
  4927. }
  4928. }
  4929. declare module BABYLON {
  4930. /** @hidden */
  4931. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4932. process(preprocessors: {
  4933. [key: string]: string;
  4934. }, options: ProcessingOptions): string;
  4935. }
  4936. }
  4937. declare module BABYLON {
  4938. /** @hidden */
  4939. export class ShaderDefineExpression {
  4940. isTrue(preprocessors: {
  4941. [key: string]: string;
  4942. }): boolean;
  4943. }
  4944. }
  4945. declare module BABYLON {
  4946. /** @hidden */
  4947. export class ShaderCodeTestNode extends ShaderCodeNode {
  4948. testExpression: ShaderDefineExpression;
  4949. isValid(preprocessors: {
  4950. [key: string]: string;
  4951. }): boolean;
  4952. }
  4953. }
  4954. declare module BABYLON {
  4955. /** @hidden */
  4956. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4957. define: string;
  4958. not: boolean;
  4959. constructor(define: string, not?: boolean);
  4960. isTrue(preprocessors: {
  4961. [key: string]: string;
  4962. }): boolean;
  4963. }
  4964. }
  4965. declare module BABYLON {
  4966. /** @hidden */
  4967. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4968. leftOperand: ShaderDefineExpression;
  4969. rightOperand: ShaderDefineExpression;
  4970. isTrue(preprocessors: {
  4971. [key: string]: string;
  4972. }): boolean;
  4973. }
  4974. }
  4975. declare module BABYLON {
  4976. /** @hidden */
  4977. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4978. leftOperand: ShaderDefineExpression;
  4979. rightOperand: ShaderDefineExpression;
  4980. isTrue(preprocessors: {
  4981. [key: string]: string;
  4982. }): boolean;
  4983. }
  4984. }
  4985. declare module BABYLON {
  4986. /** @hidden */
  4987. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4988. define: string;
  4989. operand: string;
  4990. testValue: string;
  4991. constructor(define: string, operand: string, testValue: string);
  4992. isTrue(preprocessors: {
  4993. [key: string]: string;
  4994. }): boolean;
  4995. }
  4996. }
  4997. declare module BABYLON {
  4998. /**
  4999. * @ignore
  5000. * Application error to support additional information when loading a file
  5001. */
  5002. export class LoadFileError extends Error {
  5003. /** defines the optional web request */
  5004. request?: WebRequest | undefined;
  5005. private static _setPrototypeOf;
  5006. /**
  5007. * Creates a new LoadFileError
  5008. * @param message defines the message of the error
  5009. * @param request defines the optional web request
  5010. */
  5011. constructor(message: string,
  5012. /** defines the optional web request */
  5013. request?: WebRequest | undefined);
  5014. }
  5015. }
  5016. declare module BABYLON {
  5017. /**
  5018. * Class used to enable access to offline support
  5019. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  5020. */
  5021. export interface IOfflineProvider {
  5022. /**
  5023. * Gets a boolean indicating if scene must be saved in the database
  5024. */
  5025. enableSceneOffline: boolean;
  5026. /**
  5027. * Gets a boolean indicating if textures must be saved in the database
  5028. */
  5029. enableTexturesOffline: boolean;
  5030. /**
  5031. * Open the offline support and make it available
  5032. * @param successCallback defines the callback to call on success
  5033. * @param errorCallback defines the callback to call on error
  5034. */
  5035. open(successCallback: () => void, errorCallback: () => void): void;
  5036. /**
  5037. * Loads an image from the offline support
  5038. * @param url defines the url to load from
  5039. * @param image defines the target DOM image
  5040. */
  5041. loadImage(url: string, image: HTMLImageElement): void;
  5042. /**
  5043. * Loads a file from offline support
  5044. * @param url defines the URL to load from
  5045. * @param sceneLoaded defines a callback to call on success
  5046. * @param progressCallBack defines a callback to call when progress changed
  5047. * @param errorCallback defines a callback to call on error
  5048. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  5049. */
  5050. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  5051. }
  5052. }
  5053. declare module BABYLON {
  5054. /**
  5055. * Class used to help managing file picking and drag'n'drop
  5056. * File Storage
  5057. */
  5058. export class FilesInputStore {
  5059. /**
  5060. * List of files ready to be loaded
  5061. */
  5062. static FilesToLoad: {
  5063. [key: string]: File;
  5064. };
  5065. }
  5066. }
  5067. declare module BABYLON {
  5068. /**
  5069. * Class used to define a retry strategy when error happens while loading assets
  5070. */
  5071. export class RetryStrategy {
  5072. /**
  5073. * Function used to defines an exponential back off strategy
  5074. * @param maxRetries defines the maximum number of retries (3 by default)
  5075. * @param baseInterval defines the interval between retries
  5076. * @returns the strategy function to use
  5077. */
  5078. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  5079. }
  5080. }
  5081. declare module BABYLON {
  5082. /**
  5083. * @hidden
  5084. */
  5085. export class FileTools {
  5086. /**
  5087. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  5088. */
  5089. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  5090. /**
  5091. * Gets or sets the base URL to use to load assets
  5092. */
  5093. static BaseUrl: string;
  5094. /**
  5095. * Default behaviour for cors in the application.
  5096. * It can be a string if the expected behavior is identical in the entire app.
  5097. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  5098. */
  5099. static CorsBehavior: string | ((url: string | string[]) => string);
  5100. /**
  5101. * Gets or sets a function used to pre-process url before using them to load assets
  5102. */
  5103. static PreprocessUrl: (url: string) => string;
  5104. /**
  5105. * Removes unwanted characters from an url
  5106. * @param url defines the url to clean
  5107. * @returns the cleaned url
  5108. */
  5109. private static _CleanUrl;
  5110. /**
  5111. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  5112. * @param url define the url we are trying
  5113. * @param element define the dom element where to configure the cors policy
  5114. */
  5115. static SetCorsBehavior(url: string | string[], element: {
  5116. crossOrigin: string | null;
  5117. }): void;
  5118. /**
  5119. * Loads an image as an HTMLImageElement.
  5120. * @param input url string, ArrayBuffer, or Blob to load
  5121. * @param onLoad callback called when the image successfully loads
  5122. * @param onError callback called when the image fails to load
  5123. * @param offlineProvider offline provider for caching
  5124. * @returns the HTMLImageElement of the loaded image
  5125. */
  5126. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  5127. /**
  5128. * Loads a file
  5129. * @param fileToLoad defines the file to load
  5130. * @param callback defines the callback to call when data is loaded
  5131. * @param progressCallBack defines the callback to call during loading process
  5132. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  5133. * @returns a file request object
  5134. */
  5135. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  5136. /**
  5137. * Loads a file
  5138. * @param url url string, ArrayBuffer, or Blob to load
  5139. * @param onSuccess callback called when the file successfully loads
  5140. * @param onProgress callback called while file is loading (if the server supports this mode)
  5141. * @param offlineProvider defines the offline provider for caching
  5142. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  5143. * @param onError callback called when the file fails to load
  5144. * @returns a file request object
  5145. */
  5146. 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;
  5147. /**
  5148. * Checks if the loaded document was accessed via `file:`-Protocol.
  5149. * @returns boolean
  5150. */
  5151. static IsFileURL(): boolean;
  5152. }
  5153. }
  5154. declare module BABYLON {
  5155. /** @hidden */
  5156. export class ShaderProcessor {
  5157. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5158. private static _ProcessPrecision;
  5159. private static _ExtractOperation;
  5160. private static _BuildSubExpression;
  5161. private static _BuildExpression;
  5162. private static _MoveCursorWithinIf;
  5163. private static _MoveCursor;
  5164. private static _EvaluatePreProcessors;
  5165. private static _PreparePreProcessors;
  5166. private static _ProcessShaderConversion;
  5167. private static _ProcessIncludes;
  5168. }
  5169. }
  5170. declare module BABYLON {
  5171. /**
  5172. * Interface used to define common properties for effect fallbacks
  5173. */
  5174. export interface IEffectFallbacks {
  5175. /**
  5176. * Removes the defines that should be removed when falling back.
  5177. * @param currentDefines defines the current define statements for the shader.
  5178. * @param effect defines the current effect we try to compile
  5179. * @returns The resulting defines with defines of the current rank removed.
  5180. */
  5181. reduce(currentDefines: string, effect: Effect): string;
  5182. /**
  5183. * Removes the fallback from the bound mesh.
  5184. */
  5185. unBindMesh(): void;
  5186. /**
  5187. * Checks to see if more fallbacks are still availible.
  5188. */
  5189. hasMoreFallbacks: boolean;
  5190. }
  5191. }
  5192. declare module BABYLON {
  5193. /**
  5194. * Class used to evalaute queries containing `and` and `or` operators
  5195. */
  5196. export class AndOrNotEvaluator {
  5197. /**
  5198. * Evaluate a query
  5199. * @param query defines the query to evaluate
  5200. * @param evaluateCallback defines the callback used to filter result
  5201. * @returns true if the query matches
  5202. */
  5203. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5204. private static _HandleParenthesisContent;
  5205. private static _SimplifyNegation;
  5206. }
  5207. }
  5208. declare module BABYLON {
  5209. /**
  5210. * Class used to store custom tags
  5211. */
  5212. export class Tags {
  5213. /**
  5214. * Adds support for tags on the given object
  5215. * @param obj defines the object to use
  5216. */
  5217. static EnableFor(obj: any): void;
  5218. /**
  5219. * Removes tags support
  5220. * @param obj defines the object to use
  5221. */
  5222. static DisableFor(obj: any): void;
  5223. /**
  5224. * Gets a boolean indicating if the given object has tags
  5225. * @param obj defines the object to use
  5226. * @returns a boolean
  5227. */
  5228. static HasTags(obj: any): boolean;
  5229. /**
  5230. * Gets the tags available on a given object
  5231. * @param obj defines the object to use
  5232. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5233. * @returns the tags
  5234. */
  5235. static GetTags(obj: any, asString?: boolean): any;
  5236. /**
  5237. * Adds tags to an object
  5238. * @param obj defines the object to use
  5239. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5240. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5241. */
  5242. static AddTagsTo(obj: any, tagsString: string): void;
  5243. /**
  5244. * @hidden
  5245. */
  5246. static _AddTagTo(obj: any, tag: string): void;
  5247. /**
  5248. * Removes specific tags from a specific object
  5249. * @param obj defines the object to use
  5250. * @param tagsString defines the tags to remove
  5251. */
  5252. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5253. /**
  5254. * @hidden
  5255. */
  5256. static _RemoveTagFrom(obj: any, tag: string): void;
  5257. /**
  5258. * Defines if tags hosted on an object match a given query
  5259. * @param obj defines the object to use
  5260. * @param tagsQuery defines the tag query
  5261. * @returns a boolean
  5262. */
  5263. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5264. }
  5265. }
  5266. declare module BABYLON {
  5267. /**
  5268. * Defines potential orientation for back face culling
  5269. */
  5270. export enum Orientation {
  5271. /**
  5272. * Clockwise
  5273. */
  5274. CW = 0,
  5275. /** Counter clockwise */
  5276. CCW = 1
  5277. }
  5278. /** Class used to represent a Bezier curve */
  5279. export class BezierCurve {
  5280. /**
  5281. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5282. * @param t defines the time
  5283. * @param x1 defines the left coordinate on X axis
  5284. * @param y1 defines the left coordinate on Y axis
  5285. * @param x2 defines the right coordinate on X axis
  5286. * @param y2 defines the right coordinate on Y axis
  5287. * @returns the interpolated value
  5288. */
  5289. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5290. }
  5291. /**
  5292. * Defines angle representation
  5293. */
  5294. export class Angle {
  5295. private _radians;
  5296. /**
  5297. * Creates an Angle object of "radians" radians (float).
  5298. * @param radians the angle in radians
  5299. */
  5300. constructor(radians: number);
  5301. /**
  5302. * Get value in degrees
  5303. * @returns the Angle value in degrees (float)
  5304. */
  5305. degrees(): number;
  5306. /**
  5307. * Get value in radians
  5308. * @returns the Angle value in radians (float)
  5309. */
  5310. radians(): number;
  5311. /**
  5312. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5313. * @param a defines first vector
  5314. * @param b defines second vector
  5315. * @returns a new Angle
  5316. */
  5317. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5318. /**
  5319. * Gets a new Angle object from the given float in radians
  5320. * @param radians defines the angle value in radians
  5321. * @returns a new Angle
  5322. */
  5323. static FromRadians(radians: number): Angle;
  5324. /**
  5325. * Gets a new Angle object from the given float in degrees
  5326. * @param degrees defines the angle value in degrees
  5327. * @returns a new Angle
  5328. */
  5329. static FromDegrees(degrees: number): Angle;
  5330. }
  5331. /**
  5332. * This represents an arc in a 2d space.
  5333. */
  5334. export class Arc2 {
  5335. /** Defines the start point of the arc */
  5336. startPoint: Vector2;
  5337. /** Defines the mid point of the arc */
  5338. midPoint: Vector2;
  5339. /** Defines the end point of the arc */
  5340. endPoint: Vector2;
  5341. /**
  5342. * Defines the center point of the arc.
  5343. */
  5344. centerPoint: Vector2;
  5345. /**
  5346. * Defines the radius of the arc.
  5347. */
  5348. radius: number;
  5349. /**
  5350. * Defines the angle of the arc (from mid point to end point).
  5351. */
  5352. angle: Angle;
  5353. /**
  5354. * Defines the start angle of the arc (from start point to middle point).
  5355. */
  5356. startAngle: Angle;
  5357. /**
  5358. * Defines the orientation of the arc (clock wise/counter clock wise).
  5359. */
  5360. orientation: Orientation;
  5361. /**
  5362. * Creates an Arc object from the three given points : start, middle and end.
  5363. * @param startPoint Defines the start point of the arc
  5364. * @param midPoint Defines the midlle point of the arc
  5365. * @param endPoint Defines the end point of the arc
  5366. */
  5367. constructor(
  5368. /** Defines the start point of the arc */
  5369. startPoint: Vector2,
  5370. /** Defines the mid point of the arc */
  5371. midPoint: Vector2,
  5372. /** Defines the end point of the arc */
  5373. endPoint: Vector2);
  5374. }
  5375. /**
  5376. * Represents a 2D path made up of multiple 2D points
  5377. */
  5378. export class Path2 {
  5379. private _points;
  5380. private _length;
  5381. /**
  5382. * If the path start and end point are the same
  5383. */
  5384. closed: boolean;
  5385. /**
  5386. * Creates a Path2 object from the starting 2D coordinates x and y.
  5387. * @param x the starting points x value
  5388. * @param y the starting points y value
  5389. */
  5390. constructor(x: number, y: number);
  5391. /**
  5392. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5393. * @param x the added points x value
  5394. * @param y the added points y value
  5395. * @returns the updated Path2.
  5396. */
  5397. addLineTo(x: number, y: number): Path2;
  5398. /**
  5399. * 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.
  5400. * @param midX middle point x value
  5401. * @param midY middle point y value
  5402. * @param endX end point x value
  5403. * @param endY end point y value
  5404. * @param numberOfSegments (default: 36)
  5405. * @returns the updated Path2.
  5406. */
  5407. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5408. /**
  5409. * Closes the Path2.
  5410. * @returns the Path2.
  5411. */
  5412. close(): Path2;
  5413. /**
  5414. * Gets the sum of the distance between each sequential point in the path
  5415. * @returns the Path2 total length (float).
  5416. */
  5417. length(): number;
  5418. /**
  5419. * Gets the points which construct the path
  5420. * @returns the Path2 internal array of points.
  5421. */
  5422. getPoints(): Vector2[];
  5423. /**
  5424. * Retreives the point at the distance aways from the starting point
  5425. * @param normalizedLengthPosition the length along the path to retreive the point from
  5426. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5427. */
  5428. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5429. /**
  5430. * Creates a new path starting from an x and y position
  5431. * @param x starting x value
  5432. * @param y starting y value
  5433. * @returns a new Path2 starting at the coordinates (x, y).
  5434. */
  5435. static StartingAt(x: number, y: number): Path2;
  5436. }
  5437. /**
  5438. * Represents a 3D path made up of multiple 3D points
  5439. */
  5440. export class Path3D {
  5441. /**
  5442. * an array of Vector3, the curve axis of the Path3D
  5443. */
  5444. path: Vector3[];
  5445. private _curve;
  5446. private _distances;
  5447. private _tangents;
  5448. private _normals;
  5449. private _binormals;
  5450. private _raw;
  5451. /**
  5452. * new Path3D(path, normal, raw)
  5453. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5454. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5455. * @param path an array of Vector3, the curve axis of the Path3D
  5456. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5457. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5458. */
  5459. constructor(
  5460. /**
  5461. * an array of Vector3, the curve axis of the Path3D
  5462. */
  5463. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5464. /**
  5465. * Returns the Path3D array of successive Vector3 designing its curve.
  5466. * @returns the Path3D array of successive Vector3 designing its curve.
  5467. */
  5468. getCurve(): Vector3[];
  5469. /**
  5470. * Returns an array populated with tangent vectors on each Path3D curve point.
  5471. * @returns an array populated with tangent vectors on each Path3D curve point.
  5472. */
  5473. getTangents(): Vector3[];
  5474. /**
  5475. * Returns an array populated with normal vectors on each Path3D curve point.
  5476. * @returns an array populated with normal vectors on each Path3D curve point.
  5477. */
  5478. getNormals(): Vector3[];
  5479. /**
  5480. * Returns an array populated with binormal vectors on each Path3D curve point.
  5481. * @returns an array populated with binormal vectors on each Path3D curve point.
  5482. */
  5483. getBinormals(): Vector3[];
  5484. /**
  5485. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5486. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5487. */
  5488. getDistances(): number[];
  5489. /**
  5490. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5491. * @param path path which all values are copied into the curves points
  5492. * @param firstNormal which should be projected onto the curve
  5493. * @returns the same object updated.
  5494. */
  5495. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5496. private _compute;
  5497. private _getFirstNonNullVector;
  5498. private _getLastNonNullVector;
  5499. private _normalVector;
  5500. }
  5501. /**
  5502. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5503. * A Curve3 is designed from a series of successive Vector3.
  5504. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5505. */
  5506. export class Curve3 {
  5507. private _points;
  5508. private _length;
  5509. /**
  5510. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5511. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5512. * @param v1 (Vector3) the control point
  5513. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5514. * @param nbPoints (integer) the wanted number of points in the curve
  5515. * @returns the created Curve3
  5516. */
  5517. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5518. /**
  5519. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5520. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5521. * @param v1 (Vector3) the first control point
  5522. * @param v2 (Vector3) the second control point
  5523. * @param v3 (Vector3) the end point of the Cubic Bezier
  5524. * @param nbPoints (integer) the wanted number of points in the curve
  5525. * @returns the created Curve3
  5526. */
  5527. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5528. /**
  5529. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5530. * @param p1 (Vector3) the origin point of the Hermite Spline
  5531. * @param t1 (Vector3) the tangent vector at the origin point
  5532. * @param p2 (Vector3) the end point of the Hermite Spline
  5533. * @param t2 (Vector3) the tangent vector at the end point
  5534. * @param nbPoints (integer) the wanted number of points in the curve
  5535. * @returns the created Curve3
  5536. */
  5537. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5538. /**
  5539. * Returns a Curve3 object along a CatmullRom Spline curve :
  5540. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5541. * @param nbPoints (integer) the wanted number of points between each curve control points
  5542. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5543. * @returns the created Curve3
  5544. */
  5545. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5546. /**
  5547. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5548. * A Curve3 is designed from a series of successive Vector3.
  5549. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5550. * @param points points which make up the curve
  5551. */
  5552. constructor(points: Vector3[]);
  5553. /**
  5554. * @returns the Curve3 stored array of successive Vector3
  5555. */
  5556. getPoints(): Vector3[];
  5557. /**
  5558. * @returns the computed length (float) of the curve.
  5559. */
  5560. length(): number;
  5561. /**
  5562. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5563. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5564. * curveA and curveB keep unchanged.
  5565. * @param curve the curve to continue from this curve
  5566. * @returns the newly constructed curve
  5567. */
  5568. continue(curve: DeepImmutable<Curve3>): Curve3;
  5569. private _computeLength;
  5570. }
  5571. }
  5572. declare module BABYLON {
  5573. /**
  5574. * This represents the main contract an easing function should follow.
  5575. * Easing functions are used throughout the animation system.
  5576. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5577. */
  5578. export interface IEasingFunction {
  5579. /**
  5580. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5581. * of the easing function.
  5582. * The link below provides some of the most common examples of easing functions.
  5583. * @see https://easings.net/
  5584. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5585. * @returns the corresponding value on the curve defined by the easing function
  5586. */
  5587. ease(gradient: number): number;
  5588. }
  5589. /**
  5590. * Base class used for every default easing function.
  5591. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5592. */
  5593. export class EasingFunction implements IEasingFunction {
  5594. /**
  5595. * Interpolation follows the mathematical formula associated with the easing function.
  5596. */
  5597. static readonly EASINGMODE_EASEIN: number;
  5598. /**
  5599. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5600. */
  5601. static readonly EASINGMODE_EASEOUT: number;
  5602. /**
  5603. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5604. */
  5605. static readonly EASINGMODE_EASEINOUT: number;
  5606. private _easingMode;
  5607. /**
  5608. * Sets the easing mode of the current function.
  5609. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5610. */
  5611. setEasingMode(easingMode: number): void;
  5612. /**
  5613. * Gets the current easing mode.
  5614. * @returns the easing mode
  5615. */
  5616. getEasingMode(): number;
  5617. /**
  5618. * @hidden
  5619. */
  5620. easeInCore(gradient: number): number;
  5621. /**
  5622. * Given an input gradient between 0 and 1, this returns the corresponding value
  5623. * of the easing function.
  5624. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5625. * @returns the corresponding value on the curve defined by the easing function
  5626. */
  5627. ease(gradient: number): number;
  5628. }
  5629. /**
  5630. * Easing function with a circle shape (see link below).
  5631. * @see https://easings.net/#easeInCirc
  5632. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5633. */
  5634. export class CircleEase extends EasingFunction implements IEasingFunction {
  5635. /** @hidden */
  5636. easeInCore(gradient: number): number;
  5637. }
  5638. /**
  5639. * Easing function with a ease back shape (see link below).
  5640. * @see https://easings.net/#easeInBack
  5641. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5642. */
  5643. export class BackEase extends EasingFunction implements IEasingFunction {
  5644. /** Defines the amplitude of the function */
  5645. amplitude: number;
  5646. /**
  5647. * Instantiates a back ease easing
  5648. * @see https://easings.net/#easeInBack
  5649. * @param amplitude Defines the amplitude of the function
  5650. */
  5651. constructor(
  5652. /** Defines the amplitude of the function */
  5653. amplitude?: number);
  5654. /** @hidden */
  5655. easeInCore(gradient: number): number;
  5656. }
  5657. /**
  5658. * Easing function with a bouncing shape (see link below).
  5659. * @see https://easings.net/#easeInBounce
  5660. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5661. */
  5662. export class BounceEase extends EasingFunction implements IEasingFunction {
  5663. /** Defines the number of bounces */
  5664. bounces: number;
  5665. /** Defines the amplitude of the bounce */
  5666. bounciness: number;
  5667. /**
  5668. * Instantiates a bounce easing
  5669. * @see https://easings.net/#easeInBounce
  5670. * @param bounces Defines the number of bounces
  5671. * @param bounciness Defines the amplitude of the bounce
  5672. */
  5673. constructor(
  5674. /** Defines the number of bounces */
  5675. bounces?: number,
  5676. /** Defines the amplitude of the bounce */
  5677. bounciness?: number);
  5678. /** @hidden */
  5679. easeInCore(gradient: number): number;
  5680. }
  5681. /**
  5682. * Easing function with a power of 3 shape (see link below).
  5683. * @see https://easings.net/#easeInCubic
  5684. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5685. */
  5686. export class CubicEase extends EasingFunction implements IEasingFunction {
  5687. /** @hidden */
  5688. easeInCore(gradient: number): number;
  5689. }
  5690. /**
  5691. * Easing function with an elastic shape (see link below).
  5692. * @see https://easings.net/#easeInElastic
  5693. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5694. */
  5695. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5696. /** Defines the number of oscillations*/
  5697. oscillations: number;
  5698. /** Defines the amplitude of the oscillations*/
  5699. springiness: number;
  5700. /**
  5701. * Instantiates an elastic easing function
  5702. * @see https://easings.net/#easeInElastic
  5703. * @param oscillations Defines the number of oscillations
  5704. * @param springiness Defines the amplitude of the oscillations
  5705. */
  5706. constructor(
  5707. /** Defines the number of oscillations*/
  5708. oscillations?: number,
  5709. /** Defines the amplitude of the oscillations*/
  5710. springiness?: number);
  5711. /** @hidden */
  5712. easeInCore(gradient: number): number;
  5713. }
  5714. /**
  5715. * Easing function with an exponential shape (see link below).
  5716. * @see https://easings.net/#easeInExpo
  5717. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5718. */
  5719. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5720. /** Defines the exponent of the function */
  5721. exponent: number;
  5722. /**
  5723. * Instantiates an exponential easing function
  5724. * @see https://easings.net/#easeInExpo
  5725. * @param exponent Defines the exponent of the function
  5726. */
  5727. constructor(
  5728. /** Defines the exponent of the function */
  5729. exponent?: number);
  5730. /** @hidden */
  5731. easeInCore(gradient: number): number;
  5732. }
  5733. /**
  5734. * Easing function with a power shape (see link below).
  5735. * @see https://easings.net/#easeInQuad
  5736. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5737. */
  5738. export class PowerEase extends EasingFunction implements IEasingFunction {
  5739. /** Defines the power of the function */
  5740. power: number;
  5741. /**
  5742. * Instantiates an power base easing function
  5743. * @see https://easings.net/#easeInQuad
  5744. * @param power Defines the power of the function
  5745. */
  5746. constructor(
  5747. /** Defines the power of the function */
  5748. power?: number);
  5749. /** @hidden */
  5750. easeInCore(gradient: number): number;
  5751. }
  5752. /**
  5753. * Easing function with a power of 2 shape (see link below).
  5754. * @see https://easings.net/#easeInQuad
  5755. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5756. */
  5757. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5758. /** @hidden */
  5759. easeInCore(gradient: number): number;
  5760. }
  5761. /**
  5762. * Easing function with a power of 4 shape (see link below).
  5763. * @see https://easings.net/#easeInQuart
  5764. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5765. */
  5766. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5767. /** @hidden */
  5768. easeInCore(gradient: number): number;
  5769. }
  5770. /**
  5771. * Easing function with a power of 5 shape (see link below).
  5772. * @see https://easings.net/#easeInQuint
  5773. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5774. */
  5775. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5776. /** @hidden */
  5777. easeInCore(gradient: number): number;
  5778. }
  5779. /**
  5780. * Easing function with a sin shape (see link below).
  5781. * @see https://easings.net/#easeInSine
  5782. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5783. */
  5784. export class SineEase extends EasingFunction implements IEasingFunction {
  5785. /** @hidden */
  5786. easeInCore(gradient: number): number;
  5787. }
  5788. /**
  5789. * Easing function with a bezier shape (see link below).
  5790. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5791. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5792. */
  5793. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5794. /** Defines the x component of the start tangent in the bezier curve */
  5795. x1: number;
  5796. /** Defines the y component of the start tangent in the bezier curve */
  5797. y1: number;
  5798. /** Defines the x component of the end tangent in the bezier curve */
  5799. x2: number;
  5800. /** Defines the y component of the end tangent in the bezier curve */
  5801. y2: number;
  5802. /**
  5803. * Instantiates a bezier function
  5804. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5805. * @param x1 Defines the x component of the start tangent in the bezier curve
  5806. * @param y1 Defines the y component of the start tangent in the bezier curve
  5807. * @param x2 Defines the x component of the end tangent in the bezier curve
  5808. * @param y2 Defines the y component of the end tangent in the bezier curve
  5809. */
  5810. constructor(
  5811. /** Defines the x component of the start tangent in the bezier curve */
  5812. x1?: number,
  5813. /** Defines the y component of the start tangent in the bezier curve */
  5814. y1?: number,
  5815. /** Defines the x component of the end tangent in the bezier curve */
  5816. x2?: number,
  5817. /** Defines the y component of the end tangent in the bezier curve */
  5818. y2?: number);
  5819. /** @hidden */
  5820. easeInCore(gradient: number): number;
  5821. }
  5822. }
  5823. declare module BABYLON {
  5824. /**
  5825. * Defines an interface which represents an animation key frame
  5826. */
  5827. export interface IAnimationKey {
  5828. /**
  5829. * Frame of the key frame
  5830. */
  5831. frame: number;
  5832. /**
  5833. * Value at the specifies key frame
  5834. */
  5835. value: any;
  5836. /**
  5837. * The input tangent for the cubic hermite spline
  5838. */
  5839. inTangent?: any;
  5840. /**
  5841. * The output tangent for the cubic hermite spline
  5842. */
  5843. outTangent?: any;
  5844. /**
  5845. * The animation interpolation type
  5846. */
  5847. interpolation?: AnimationKeyInterpolation;
  5848. }
  5849. /**
  5850. * Enum for the animation key frame interpolation type
  5851. */
  5852. export enum AnimationKeyInterpolation {
  5853. /**
  5854. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5855. */
  5856. STEP = 1
  5857. }
  5858. }
  5859. declare module BABYLON {
  5860. /**
  5861. * Represents the range of an animation
  5862. */
  5863. export class AnimationRange {
  5864. /**The name of the animation range**/
  5865. name: string;
  5866. /**The starting frame of the animation */
  5867. from: number;
  5868. /**The ending frame of the animation*/
  5869. to: number;
  5870. /**
  5871. * Initializes the range of an animation
  5872. * @param name The name of the animation range
  5873. * @param from The starting frame of the animation
  5874. * @param to The ending frame of the animation
  5875. */
  5876. constructor(
  5877. /**The name of the animation range**/
  5878. name: string,
  5879. /**The starting frame of the animation */
  5880. from: number,
  5881. /**The ending frame of the animation*/
  5882. to: number);
  5883. /**
  5884. * Makes a copy of the animation range
  5885. * @returns A copy of the animation range
  5886. */
  5887. clone(): AnimationRange;
  5888. }
  5889. }
  5890. declare module BABYLON {
  5891. /**
  5892. * Composed of a frame, and an action function
  5893. */
  5894. export class AnimationEvent {
  5895. /** The frame for which the event is triggered **/
  5896. frame: number;
  5897. /** The event to perform when triggered **/
  5898. action: (currentFrame: number) => void;
  5899. /** Specifies if the event should be triggered only once**/
  5900. onlyOnce?: boolean | undefined;
  5901. /**
  5902. * Specifies if the animation event is done
  5903. */
  5904. isDone: boolean;
  5905. /**
  5906. * Initializes the animation event
  5907. * @param frame The frame for which the event is triggered
  5908. * @param action The event to perform when triggered
  5909. * @param onlyOnce Specifies if the event should be triggered only once
  5910. */
  5911. constructor(
  5912. /** The frame for which the event is triggered **/
  5913. frame: number,
  5914. /** The event to perform when triggered **/
  5915. action: (currentFrame: number) => void,
  5916. /** Specifies if the event should be triggered only once**/
  5917. onlyOnce?: boolean | undefined);
  5918. /** @hidden */
  5919. _clone(): AnimationEvent;
  5920. }
  5921. }
  5922. declare module BABYLON {
  5923. /**
  5924. * Interface used to define a behavior
  5925. */
  5926. export interface Behavior<T> {
  5927. /** gets or sets behavior's name */
  5928. name: string;
  5929. /**
  5930. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5931. */
  5932. init(): void;
  5933. /**
  5934. * Called when the behavior is attached to a target
  5935. * @param target defines the target where the behavior is attached to
  5936. */
  5937. attach(target: T): void;
  5938. /**
  5939. * Called when the behavior is detached from its target
  5940. */
  5941. detach(): void;
  5942. }
  5943. /**
  5944. * Interface implemented by classes supporting behaviors
  5945. */
  5946. export interface IBehaviorAware<T> {
  5947. /**
  5948. * Attach a behavior
  5949. * @param behavior defines the behavior to attach
  5950. * @returns the current host
  5951. */
  5952. addBehavior(behavior: Behavior<T>): T;
  5953. /**
  5954. * Remove a behavior from the current object
  5955. * @param behavior defines the behavior to detach
  5956. * @returns the current host
  5957. */
  5958. removeBehavior(behavior: Behavior<T>): T;
  5959. /**
  5960. * Gets a behavior using its name to search
  5961. * @param name defines the name to search
  5962. * @returns the behavior or null if not found
  5963. */
  5964. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5965. }
  5966. }
  5967. declare module BABYLON {
  5968. /**
  5969. * Defines an array and its length.
  5970. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5971. */
  5972. export interface ISmartArrayLike<T> {
  5973. /**
  5974. * The data of the array.
  5975. */
  5976. data: Array<T>;
  5977. /**
  5978. * The active length of the array.
  5979. */
  5980. length: number;
  5981. }
  5982. /**
  5983. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5984. */
  5985. export class SmartArray<T> implements ISmartArrayLike<T> {
  5986. /**
  5987. * The full set of data from the array.
  5988. */
  5989. data: Array<T>;
  5990. /**
  5991. * The active length of the array.
  5992. */
  5993. length: number;
  5994. protected _id: number;
  5995. /**
  5996. * Instantiates a Smart Array.
  5997. * @param capacity defines the default capacity of the array.
  5998. */
  5999. constructor(capacity: number);
  6000. /**
  6001. * Pushes a value at the end of the active data.
  6002. * @param value defines the object to push in the array.
  6003. */
  6004. push(value: T): void;
  6005. /**
  6006. * Iterates over the active data and apply the lambda to them.
  6007. * @param func defines the action to apply on each value.
  6008. */
  6009. forEach(func: (content: T) => void): void;
  6010. /**
  6011. * Sorts the full sets of data.
  6012. * @param compareFn defines the comparison function to apply.
  6013. */
  6014. sort(compareFn: (a: T, b: T) => number): void;
  6015. /**
  6016. * Resets the active data to an empty array.
  6017. */
  6018. reset(): void;
  6019. /**
  6020. * Releases all the data from the array as well as the array.
  6021. */
  6022. dispose(): void;
  6023. /**
  6024. * Concats the active data with a given array.
  6025. * @param array defines the data to concatenate with.
  6026. */
  6027. concat(array: any): void;
  6028. /**
  6029. * Returns the position of a value in the active data.
  6030. * @param value defines the value to find the index for
  6031. * @returns the index if found in the active data otherwise -1
  6032. */
  6033. indexOf(value: T): number;
  6034. /**
  6035. * Returns whether an element is part of the active data.
  6036. * @param value defines the value to look for
  6037. * @returns true if found in the active data otherwise false
  6038. */
  6039. contains(value: T): boolean;
  6040. private static _GlobalId;
  6041. }
  6042. /**
  6043. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6044. * The data in this array can only be present once
  6045. */
  6046. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6047. private _duplicateId;
  6048. /**
  6049. * Pushes a value at the end of the active data.
  6050. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6051. * @param value defines the object to push in the array.
  6052. */
  6053. push(value: T): void;
  6054. /**
  6055. * Pushes a value at the end of the active data.
  6056. * If the data is already present, it won t be added again
  6057. * @param value defines the object to push in the array.
  6058. * @returns true if added false if it was already present
  6059. */
  6060. pushNoDuplicate(value: T): boolean;
  6061. /**
  6062. * Resets the active data to an empty array.
  6063. */
  6064. reset(): void;
  6065. /**
  6066. * Concats the active data with a given array.
  6067. * This ensures no dupplicate will be present in the result.
  6068. * @param array defines the data to concatenate with.
  6069. */
  6070. concatWithNoDuplicate(array: any): void;
  6071. }
  6072. }
  6073. declare module BABYLON {
  6074. /**
  6075. * @ignore
  6076. * This is a list of all the different input types that are available in the application.
  6077. * Fo instance: ArcRotateCameraGamepadInput...
  6078. */
  6079. export var CameraInputTypes: {};
  6080. /**
  6081. * This is the contract to implement in order to create a new input class.
  6082. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6083. */
  6084. export interface ICameraInput<TCamera extends Camera> {
  6085. /**
  6086. * Defines the camera the input is attached to.
  6087. */
  6088. camera: Nullable<TCamera>;
  6089. /**
  6090. * Gets the class name of the current intput.
  6091. * @returns the class name
  6092. */
  6093. getClassName(): string;
  6094. /**
  6095. * Get the friendly name associated with the input class.
  6096. * @returns the input friendly name
  6097. */
  6098. getSimpleName(): string;
  6099. /**
  6100. * Attach the input controls to a specific dom element to get the input from.
  6101. * @param element Defines the element the controls should be listened from
  6102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6103. */
  6104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6105. /**
  6106. * Detach the current controls from the specified dom element.
  6107. * @param element Defines the element to stop listening the inputs from
  6108. */
  6109. detachControl(element: Nullable<HTMLElement>): void;
  6110. /**
  6111. * Update the current camera state depending on the inputs that have been used this frame.
  6112. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6113. */
  6114. checkInputs?: () => void;
  6115. }
  6116. /**
  6117. * Represents a map of input types to input instance or input index to input instance.
  6118. */
  6119. export interface CameraInputsMap<TCamera extends Camera> {
  6120. /**
  6121. * Accessor to the input by input type.
  6122. */
  6123. [name: string]: ICameraInput<TCamera>;
  6124. /**
  6125. * Accessor to the input by input index.
  6126. */
  6127. [idx: number]: ICameraInput<TCamera>;
  6128. }
  6129. /**
  6130. * This represents the input manager used within a camera.
  6131. * It helps dealing with all the different kind of input attached to a camera.
  6132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6133. */
  6134. export class CameraInputsManager<TCamera extends Camera> {
  6135. /**
  6136. * Defines the list of inputs attahed to the camera.
  6137. */
  6138. attached: CameraInputsMap<TCamera>;
  6139. /**
  6140. * Defines the dom element the camera is collecting inputs from.
  6141. * This is null if the controls have not been attached.
  6142. */
  6143. attachedElement: Nullable<HTMLElement>;
  6144. /**
  6145. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6146. */
  6147. noPreventDefault: boolean;
  6148. /**
  6149. * Defined the camera the input manager belongs to.
  6150. */
  6151. camera: TCamera;
  6152. /**
  6153. * Update the current camera state depending on the inputs that have been used this frame.
  6154. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6155. */
  6156. checkInputs: () => void;
  6157. /**
  6158. * Instantiate a new Camera Input Manager.
  6159. * @param camera Defines the camera the input manager blongs to
  6160. */
  6161. constructor(camera: TCamera);
  6162. /**
  6163. * Add an input method to a camera
  6164. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6165. * @param input camera input method
  6166. */
  6167. add(input: ICameraInput<TCamera>): void;
  6168. /**
  6169. * Remove a specific input method from a camera
  6170. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6171. * @param inputToRemove camera input method
  6172. */
  6173. remove(inputToRemove: ICameraInput<TCamera>): void;
  6174. /**
  6175. * Remove a specific input type from a camera
  6176. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6177. * @param inputType the type of the input to remove
  6178. */
  6179. removeByType(inputType: string): void;
  6180. private _addCheckInputs;
  6181. /**
  6182. * Attach the input controls to the currently attached dom element to listen the events from.
  6183. * @param input Defines the input to attach
  6184. */
  6185. attachInput(input: ICameraInput<TCamera>): void;
  6186. /**
  6187. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6188. * @param element Defines the dom element to collect the events from
  6189. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6190. */
  6191. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6192. /**
  6193. * Detach the current manager inputs controls from a specific dom element.
  6194. * @param element Defines the dom element to collect the events from
  6195. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6196. */
  6197. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6198. /**
  6199. * Rebuild the dynamic inputCheck function from the current list of
  6200. * defined inputs in the manager.
  6201. */
  6202. rebuildInputCheck(): void;
  6203. /**
  6204. * Remove all attached input methods from a camera
  6205. */
  6206. clear(): void;
  6207. /**
  6208. * Serialize the current input manager attached to a camera.
  6209. * This ensures than once parsed,
  6210. * the input associated to the camera will be identical to the current ones
  6211. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6212. */
  6213. serialize(serializedCamera: any): void;
  6214. /**
  6215. * Parses an input manager serialized JSON to restore the previous list of inputs
  6216. * and states associated to a camera.
  6217. * @param parsedCamera Defines the JSON to parse
  6218. */
  6219. parse(parsedCamera: any): void;
  6220. }
  6221. }
  6222. declare module BABYLON {
  6223. /**
  6224. * Class used to store data that will be store in GPU memory
  6225. */
  6226. export class Buffer {
  6227. private _engine;
  6228. private _buffer;
  6229. /** @hidden */
  6230. _data: Nullable<DataArray>;
  6231. private _updatable;
  6232. private _instanced;
  6233. /**
  6234. * Gets the byte stride.
  6235. */
  6236. readonly byteStride: number;
  6237. /**
  6238. * Constructor
  6239. * @param engine the engine
  6240. * @param data the data to use for this buffer
  6241. * @param updatable whether the data is updatable
  6242. * @param stride the stride (optional)
  6243. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6244. * @param instanced whether the buffer is instanced (optional)
  6245. * @param useBytes set to true if the stride in in bytes (optional)
  6246. */
  6247. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6248. /**
  6249. * Create a new VertexBuffer based on the current buffer
  6250. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6251. * @param offset defines offset in the buffer (0 by default)
  6252. * @param size defines the size in floats of attributes (position is 3 for instance)
  6253. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6254. * @param instanced defines if the vertex buffer contains indexed data
  6255. * @param useBytes defines if the offset and stride are in bytes
  6256. * @returns the new vertex buffer
  6257. */
  6258. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6259. /**
  6260. * Gets a boolean indicating if the Buffer is updatable?
  6261. * @returns true if the buffer is updatable
  6262. */
  6263. isUpdatable(): boolean;
  6264. /**
  6265. * Gets current buffer's data
  6266. * @returns a DataArray or null
  6267. */
  6268. getData(): Nullable<DataArray>;
  6269. /**
  6270. * Gets underlying native buffer
  6271. * @returns underlying native buffer
  6272. */
  6273. getBuffer(): Nullable<DataBuffer>;
  6274. /**
  6275. * Gets the stride in float32 units (i.e. byte stride / 4).
  6276. * May not be an integer if the byte stride is not divisible by 4.
  6277. * DEPRECATED. Use byteStride instead.
  6278. * @returns the stride in float32 units
  6279. */
  6280. getStrideSize(): number;
  6281. /**
  6282. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6283. * @param data defines the data to store
  6284. */
  6285. create(data?: Nullable<DataArray>): void;
  6286. /** @hidden */
  6287. _rebuild(): void;
  6288. /**
  6289. * Update current buffer data
  6290. * @param data defines the data to store
  6291. */
  6292. update(data: DataArray): void;
  6293. /**
  6294. * Updates the data directly.
  6295. * @param data the new data
  6296. * @param offset the new offset
  6297. * @param vertexCount the vertex count (optional)
  6298. * @param useBytes set to true if the offset is in bytes
  6299. */
  6300. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6301. /**
  6302. * Release all resources
  6303. */
  6304. dispose(): void;
  6305. }
  6306. /**
  6307. * Specialized buffer used to store vertex data
  6308. */
  6309. export class VertexBuffer {
  6310. /** @hidden */
  6311. _buffer: Buffer;
  6312. private _kind;
  6313. private _size;
  6314. private _ownsBuffer;
  6315. private _instanced;
  6316. private _instanceDivisor;
  6317. /**
  6318. * The byte type.
  6319. */
  6320. static readonly BYTE: number;
  6321. /**
  6322. * The unsigned byte type.
  6323. */
  6324. static readonly UNSIGNED_BYTE: number;
  6325. /**
  6326. * The short type.
  6327. */
  6328. static readonly SHORT: number;
  6329. /**
  6330. * The unsigned short type.
  6331. */
  6332. static readonly UNSIGNED_SHORT: number;
  6333. /**
  6334. * The integer type.
  6335. */
  6336. static readonly INT: number;
  6337. /**
  6338. * The unsigned integer type.
  6339. */
  6340. static readonly UNSIGNED_INT: number;
  6341. /**
  6342. * The float type.
  6343. */
  6344. static readonly FLOAT: number;
  6345. /**
  6346. * Gets or sets the instance divisor when in instanced mode
  6347. */
  6348. instanceDivisor: number;
  6349. /**
  6350. * Gets the byte stride.
  6351. */
  6352. readonly byteStride: number;
  6353. /**
  6354. * Gets the byte offset.
  6355. */
  6356. readonly byteOffset: number;
  6357. /**
  6358. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6359. */
  6360. readonly normalized: boolean;
  6361. /**
  6362. * Gets the data type of each component in the array.
  6363. */
  6364. readonly type: number;
  6365. /**
  6366. * Constructor
  6367. * @param engine the engine
  6368. * @param data the data to use for this vertex buffer
  6369. * @param kind the vertex buffer kind
  6370. * @param updatable whether the data is updatable
  6371. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6372. * @param stride the stride (optional)
  6373. * @param instanced whether the buffer is instanced (optional)
  6374. * @param offset the offset of the data (optional)
  6375. * @param size the number of components (optional)
  6376. * @param type the type of the component (optional)
  6377. * @param normalized whether the data contains normalized data (optional)
  6378. * @param useBytes set to true if stride and offset are in bytes (optional)
  6379. */
  6380. 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);
  6381. /** @hidden */
  6382. _rebuild(): void;
  6383. /**
  6384. * Returns the kind of the VertexBuffer (string)
  6385. * @returns a string
  6386. */
  6387. getKind(): string;
  6388. /**
  6389. * Gets a boolean indicating if the VertexBuffer is updatable?
  6390. * @returns true if the buffer is updatable
  6391. */
  6392. isUpdatable(): boolean;
  6393. /**
  6394. * Gets current buffer's data
  6395. * @returns a DataArray or null
  6396. */
  6397. getData(): Nullable<DataArray>;
  6398. /**
  6399. * Gets underlying native buffer
  6400. * @returns underlying native buffer
  6401. */
  6402. getBuffer(): Nullable<DataBuffer>;
  6403. /**
  6404. * Gets the stride in float32 units (i.e. byte stride / 4).
  6405. * May not be an integer if the byte stride is not divisible by 4.
  6406. * DEPRECATED. Use byteStride instead.
  6407. * @returns the stride in float32 units
  6408. */
  6409. getStrideSize(): number;
  6410. /**
  6411. * Returns the offset as a multiple of the type byte length.
  6412. * DEPRECATED. Use byteOffset instead.
  6413. * @returns the offset in bytes
  6414. */
  6415. getOffset(): number;
  6416. /**
  6417. * Returns the number of components per vertex attribute (integer)
  6418. * @returns the size in float
  6419. */
  6420. getSize(): number;
  6421. /**
  6422. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6423. * @returns true if this buffer is instanced
  6424. */
  6425. getIsInstanced(): boolean;
  6426. /**
  6427. * Returns the instancing divisor, zero for non-instanced (integer).
  6428. * @returns a number
  6429. */
  6430. getInstanceDivisor(): number;
  6431. /**
  6432. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6433. * @param data defines the data to store
  6434. */
  6435. create(data?: DataArray): void;
  6436. /**
  6437. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6438. * This function will create a new buffer if the current one is not updatable
  6439. * @param data defines the data to store
  6440. */
  6441. update(data: DataArray): void;
  6442. /**
  6443. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6444. * Returns the directly updated WebGLBuffer.
  6445. * @param data the new data
  6446. * @param offset the new offset
  6447. * @param useBytes set to true if the offset is in bytes
  6448. */
  6449. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6450. /**
  6451. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6452. */
  6453. dispose(): void;
  6454. /**
  6455. * Enumerates each value of this vertex buffer as numbers.
  6456. * @param count the number of values to enumerate
  6457. * @param callback the callback function called for each value
  6458. */
  6459. forEach(count: number, callback: (value: number, index: number) => void): void;
  6460. /**
  6461. * Positions
  6462. */
  6463. static readonly PositionKind: string;
  6464. /**
  6465. * Normals
  6466. */
  6467. static readonly NormalKind: string;
  6468. /**
  6469. * Tangents
  6470. */
  6471. static readonly TangentKind: string;
  6472. /**
  6473. * Texture coordinates
  6474. */
  6475. static readonly UVKind: string;
  6476. /**
  6477. * Texture coordinates 2
  6478. */
  6479. static readonly UV2Kind: string;
  6480. /**
  6481. * Texture coordinates 3
  6482. */
  6483. static readonly UV3Kind: string;
  6484. /**
  6485. * Texture coordinates 4
  6486. */
  6487. static readonly UV4Kind: string;
  6488. /**
  6489. * Texture coordinates 5
  6490. */
  6491. static readonly UV5Kind: string;
  6492. /**
  6493. * Texture coordinates 6
  6494. */
  6495. static readonly UV6Kind: string;
  6496. /**
  6497. * Colors
  6498. */
  6499. static readonly ColorKind: string;
  6500. /**
  6501. * Matrix indices (for bones)
  6502. */
  6503. static readonly MatricesIndicesKind: string;
  6504. /**
  6505. * Matrix weights (for bones)
  6506. */
  6507. static readonly MatricesWeightsKind: string;
  6508. /**
  6509. * Additional matrix indices (for bones)
  6510. */
  6511. static readonly MatricesIndicesExtraKind: string;
  6512. /**
  6513. * Additional matrix weights (for bones)
  6514. */
  6515. static readonly MatricesWeightsExtraKind: string;
  6516. /**
  6517. * Deduces the stride given a kind.
  6518. * @param kind The kind string to deduce
  6519. * @returns The deduced stride
  6520. */
  6521. static DeduceStride(kind: string): number;
  6522. /**
  6523. * Gets the byte length of the given type.
  6524. * @param type the type
  6525. * @returns the number of bytes
  6526. */
  6527. static GetTypeByteLength(type: number): number;
  6528. /**
  6529. * Enumerates each value of the given parameters as numbers.
  6530. * @param data the data to enumerate
  6531. * @param byteOffset the byte offset of the data
  6532. * @param byteStride the byte stride of the data
  6533. * @param componentCount the number of components per element
  6534. * @param componentType the type of the component
  6535. * @param count the number of values to enumerate
  6536. * @param normalized whether the data is normalized
  6537. * @param callback the callback function called for each value
  6538. */
  6539. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6540. private static _GetFloatValue;
  6541. }
  6542. }
  6543. declare module BABYLON {
  6544. /**
  6545. * @hidden
  6546. */
  6547. export class IntersectionInfo {
  6548. bu: Nullable<number>;
  6549. bv: Nullable<number>;
  6550. distance: number;
  6551. faceId: number;
  6552. subMeshId: number;
  6553. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6554. }
  6555. }
  6556. declare module BABYLON {
  6557. /**
  6558. * Represens a plane by the equation ax + by + cz + d = 0
  6559. */
  6560. export class Plane {
  6561. private static _TmpMatrix;
  6562. /**
  6563. * Normal of the plane (a,b,c)
  6564. */
  6565. normal: Vector3;
  6566. /**
  6567. * d component of the plane
  6568. */
  6569. d: number;
  6570. /**
  6571. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6572. * @param a a component of the plane
  6573. * @param b b component of the plane
  6574. * @param c c component of the plane
  6575. * @param d d component of the plane
  6576. */
  6577. constructor(a: number, b: number, c: number, d: number);
  6578. /**
  6579. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6580. */
  6581. asArray(): number[];
  6582. /**
  6583. * @returns a new plane copied from the current Plane.
  6584. */
  6585. clone(): Plane;
  6586. /**
  6587. * @returns the string "Plane".
  6588. */
  6589. getClassName(): string;
  6590. /**
  6591. * @returns the Plane hash code.
  6592. */
  6593. getHashCode(): number;
  6594. /**
  6595. * Normalize the current Plane in place.
  6596. * @returns the updated Plane.
  6597. */
  6598. normalize(): Plane;
  6599. /**
  6600. * Applies a transformation the plane and returns the result
  6601. * @param transformation the transformation matrix to be applied to the plane
  6602. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6603. */
  6604. transform(transformation: DeepImmutable<Matrix>): Plane;
  6605. /**
  6606. * Calcualtte the dot product between the point and the plane normal
  6607. * @param point point to calculate the dot product with
  6608. * @returns the dot product (float) of the point coordinates and the plane normal.
  6609. */
  6610. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6611. /**
  6612. * Updates the current Plane from the plane defined by the three given points.
  6613. * @param point1 one of the points used to contruct the plane
  6614. * @param point2 one of the points used to contruct the plane
  6615. * @param point3 one of the points used to contruct the plane
  6616. * @returns the updated Plane.
  6617. */
  6618. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6619. /**
  6620. * Checks if the plane is facing a given direction
  6621. * @param direction the direction to check if the plane is facing
  6622. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6623. * @returns True is the vector "direction" is the same side than the plane normal.
  6624. */
  6625. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6626. /**
  6627. * Calculates the distance to a point
  6628. * @param point point to calculate distance to
  6629. * @returns the signed distance (float) from the given point to the Plane.
  6630. */
  6631. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6632. /**
  6633. * Creates a plane from an array
  6634. * @param array the array to create a plane from
  6635. * @returns a new Plane from the given array.
  6636. */
  6637. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6638. /**
  6639. * Creates a plane from three points
  6640. * @param point1 point used to create the plane
  6641. * @param point2 point used to create the plane
  6642. * @param point3 point used to create the plane
  6643. * @returns a new Plane defined by the three given points.
  6644. */
  6645. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6646. /**
  6647. * Creates a plane from an origin point and a normal
  6648. * @param origin origin of the plane to be constructed
  6649. * @param normal normal of the plane to be constructed
  6650. * @returns a new Plane the normal vector to this plane at the given origin point.
  6651. * Note : the vector "normal" is updated because normalized.
  6652. */
  6653. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6654. /**
  6655. * Calculates the distance from a plane and a point
  6656. * @param origin origin of the plane to be constructed
  6657. * @param normal normal of the plane to be constructed
  6658. * @param point point to calculate distance to
  6659. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6660. */
  6661. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6662. }
  6663. }
  6664. declare module BABYLON {
  6665. /**
  6666. * Class used to store bounding sphere information
  6667. */
  6668. export class BoundingSphere {
  6669. /**
  6670. * Gets the center of the bounding sphere in local space
  6671. */
  6672. readonly center: Vector3;
  6673. /**
  6674. * Radius of the bounding sphere in local space
  6675. */
  6676. radius: number;
  6677. /**
  6678. * Gets the center of the bounding sphere in world space
  6679. */
  6680. readonly centerWorld: Vector3;
  6681. /**
  6682. * Radius of the bounding sphere in world space
  6683. */
  6684. radiusWorld: number;
  6685. /**
  6686. * Gets the minimum vector in local space
  6687. */
  6688. readonly minimum: Vector3;
  6689. /**
  6690. * Gets the maximum vector in local space
  6691. */
  6692. readonly maximum: Vector3;
  6693. private _worldMatrix;
  6694. private static readonly TmpVector3;
  6695. /**
  6696. * Creates a new bounding sphere
  6697. * @param min defines the minimum vector (in local space)
  6698. * @param max defines the maximum vector (in local space)
  6699. * @param worldMatrix defines the new world matrix
  6700. */
  6701. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6702. /**
  6703. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6704. * @param min defines the new minimum vector (in local space)
  6705. * @param max defines the new maximum vector (in local space)
  6706. * @param worldMatrix defines the new world matrix
  6707. */
  6708. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6709. /**
  6710. * Scale the current bounding sphere by applying a scale factor
  6711. * @param factor defines the scale factor to apply
  6712. * @returns the current bounding box
  6713. */
  6714. scale(factor: number): BoundingSphere;
  6715. /**
  6716. * Gets the world matrix of the bounding box
  6717. * @returns a matrix
  6718. */
  6719. getWorldMatrix(): DeepImmutable<Matrix>;
  6720. /** @hidden */
  6721. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6722. /**
  6723. * Tests if the bounding sphere is intersecting the frustum planes
  6724. * @param frustumPlanes defines the frustum planes to test
  6725. * @returns true if there is an intersection
  6726. */
  6727. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6728. /**
  6729. * Tests if the bounding sphere center is in between the frustum planes.
  6730. * Used for optimistic fast inclusion.
  6731. * @param frustumPlanes defines the frustum planes to test
  6732. * @returns true if the sphere center is in between the frustum planes
  6733. */
  6734. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6735. /**
  6736. * Tests if a point is inside the bounding sphere
  6737. * @param point defines the point to test
  6738. * @returns true if the point is inside the bounding sphere
  6739. */
  6740. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6741. /**
  6742. * Checks if two sphere intersct
  6743. * @param sphere0 sphere 0
  6744. * @param sphere1 sphere 1
  6745. * @returns true if the speres intersect
  6746. */
  6747. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6748. }
  6749. }
  6750. declare module BABYLON {
  6751. /**
  6752. * Class used to store bounding box information
  6753. */
  6754. export class BoundingBox implements ICullable {
  6755. /**
  6756. * Gets the 8 vectors representing the bounding box in local space
  6757. */
  6758. readonly vectors: Vector3[];
  6759. /**
  6760. * Gets the center of the bounding box in local space
  6761. */
  6762. readonly center: Vector3;
  6763. /**
  6764. * Gets the center of the bounding box in world space
  6765. */
  6766. readonly centerWorld: Vector3;
  6767. /**
  6768. * Gets the extend size in local space
  6769. */
  6770. readonly extendSize: Vector3;
  6771. /**
  6772. * Gets the extend size in world space
  6773. */
  6774. readonly extendSizeWorld: Vector3;
  6775. /**
  6776. * Gets the OBB (object bounding box) directions
  6777. */
  6778. readonly directions: Vector3[];
  6779. /**
  6780. * Gets the 8 vectors representing the bounding box in world space
  6781. */
  6782. readonly vectorsWorld: Vector3[];
  6783. /**
  6784. * Gets the minimum vector in world space
  6785. */
  6786. readonly minimumWorld: Vector3;
  6787. /**
  6788. * Gets the maximum vector in world space
  6789. */
  6790. readonly maximumWorld: Vector3;
  6791. /**
  6792. * Gets the minimum vector in local space
  6793. */
  6794. readonly minimum: Vector3;
  6795. /**
  6796. * Gets the maximum vector in local space
  6797. */
  6798. readonly maximum: Vector3;
  6799. private _worldMatrix;
  6800. private static readonly TmpVector3;
  6801. /**
  6802. * @hidden
  6803. */
  6804. _tag: number;
  6805. /**
  6806. * Creates a new bounding box
  6807. * @param min defines the minimum vector (in local space)
  6808. * @param max defines the maximum vector (in local space)
  6809. * @param worldMatrix defines the new world matrix
  6810. */
  6811. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6812. /**
  6813. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6814. * @param min defines the new minimum vector (in local space)
  6815. * @param max defines the new maximum vector (in local space)
  6816. * @param worldMatrix defines the new world matrix
  6817. */
  6818. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6819. /**
  6820. * Scale the current bounding box by applying a scale factor
  6821. * @param factor defines the scale factor to apply
  6822. * @returns the current bounding box
  6823. */
  6824. scale(factor: number): BoundingBox;
  6825. /**
  6826. * Gets the world matrix of the bounding box
  6827. * @returns a matrix
  6828. */
  6829. getWorldMatrix(): DeepImmutable<Matrix>;
  6830. /** @hidden */
  6831. _update(world: DeepImmutable<Matrix>): void;
  6832. /**
  6833. * Tests if the bounding box is intersecting the frustum planes
  6834. * @param frustumPlanes defines the frustum planes to test
  6835. * @returns true if there is an intersection
  6836. */
  6837. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6838. /**
  6839. * Tests if the bounding box is entirely inside the frustum planes
  6840. * @param frustumPlanes defines the frustum planes to test
  6841. * @returns true if there is an inclusion
  6842. */
  6843. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6844. /**
  6845. * Tests if a point is inside the bounding box
  6846. * @param point defines the point to test
  6847. * @returns true if the point is inside the bounding box
  6848. */
  6849. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6850. /**
  6851. * Tests if the bounding box intersects with a bounding sphere
  6852. * @param sphere defines the sphere to test
  6853. * @returns true if there is an intersection
  6854. */
  6855. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6856. /**
  6857. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6858. * @param min defines the min vector to use
  6859. * @param max defines the max vector to use
  6860. * @returns true if there is an intersection
  6861. */
  6862. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6863. /**
  6864. * Tests if two bounding boxes are intersections
  6865. * @param box0 defines the first box to test
  6866. * @param box1 defines the second box to test
  6867. * @returns true if there is an intersection
  6868. */
  6869. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6870. /**
  6871. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6872. * @param minPoint defines the minimum vector of the bounding box
  6873. * @param maxPoint defines the maximum vector of the bounding box
  6874. * @param sphereCenter defines the sphere center
  6875. * @param sphereRadius defines the sphere radius
  6876. * @returns true if there is an intersection
  6877. */
  6878. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6879. /**
  6880. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6881. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @return true if there is an inclusion
  6884. */
  6885. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6888. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6889. * @param frustumPlanes defines the frustum planes to test
  6890. * @return true if there is an intersection
  6891. */
  6892. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6893. }
  6894. }
  6895. declare module BABYLON {
  6896. /** @hidden */
  6897. export class Collider {
  6898. /** Define if a collision was found */
  6899. collisionFound: boolean;
  6900. /**
  6901. * Define last intersection point in local space
  6902. */
  6903. intersectionPoint: Vector3;
  6904. /**
  6905. * Define last collided mesh
  6906. */
  6907. collidedMesh: Nullable<AbstractMesh>;
  6908. private _collisionPoint;
  6909. private _planeIntersectionPoint;
  6910. private _tempVector;
  6911. private _tempVector2;
  6912. private _tempVector3;
  6913. private _tempVector4;
  6914. private _edge;
  6915. private _baseToVertex;
  6916. private _destinationPoint;
  6917. private _slidePlaneNormal;
  6918. private _displacementVector;
  6919. /** @hidden */
  6920. _radius: Vector3;
  6921. /** @hidden */
  6922. _retry: number;
  6923. private _velocity;
  6924. private _basePoint;
  6925. private _epsilon;
  6926. /** @hidden */
  6927. _velocityWorldLength: number;
  6928. /** @hidden */
  6929. _basePointWorld: Vector3;
  6930. private _velocityWorld;
  6931. private _normalizedVelocity;
  6932. /** @hidden */
  6933. _initialVelocity: Vector3;
  6934. /** @hidden */
  6935. _initialPosition: Vector3;
  6936. private _nearestDistance;
  6937. private _collisionMask;
  6938. collisionMask: number;
  6939. /**
  6940. * Gets the plane normal used to compute the sliding response (in local space)
  6941. */
  6942. readonly slidePlaneNormal: Vector3;
  6943. /** @hidden */
  6944. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6945. /** @hidden */
  6946. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6947. /** @hidden */
  6948. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6949. /** @hidden */
  6950. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6951. /** @hidden */
  6952. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6953. /** @hidden */
  6954. _getResponse(pos: Vector3, vel: Vector3): void;
  6955. }
  6956. }
  6957. declare module BABYLON {
  6958. /**
  6959. * Interface for cullable objects
  6960. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6961. */
  6962. export interface ICullable {
  6963. /**
  6964. * Checks if the object or part of the object is in the frustum
  6965. * @param frustumPlanes Camera near/planes
  6966. * @returns true if the object is in frustum otherwise false
  6967. */
  6968. isInFrustum(frustumPlanes: Plane[]): boolean;
  6969. /**
  6970. * Checks if a cullable object (mesh...) is in the camera frustum
  6971. * Unlike isInFrustum this cheks the full bounding box
  6972. * @param frustumPlanes Camera near/planes
  6973. * @returns true if the object is in frustum otherwise false
  6974. */
  6975. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6976. }
  6977. /**
  6978. * Info for a bounding data of a mesh
  6979. */
  6980. export class BoundingInfo implements ICullable {
  6981. /**
  6982. * Bounding box for the mesh
  6983. */
  6984. readonly boundingBox: BoundingBox;
  6985. /**
  6986. * Bounding sphere for the mesh
  6987. */
  6988. readonly boundingSphere: BoundingSphere;
  6989. private _isLocked;
  6990. private static readonly TmpVector3;
  6991. /**
  6992. * Constructs bounding info
  6993. * @param minimum min vector of the bounding box/sphere
  6994. * @param maximum max vector of the bounding box/sphere
  6995. * @param worldMatrix defines the new world matrix
  6996. */
  6997. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6998. /**
  6999. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7000. * @param min defines the new minimum vector (in local space)
  7001. * @param max defines the new maximum vector (in local space)
  7002. * @param worldMatrix defines the new world matrix
  7003. */
  7004. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7005. /**
  7006. * min vector of the bounding box/sphere
  7007. */
  7008. readonly minimum: Vector3;
  7009. /**
  7010. * max vector of the bounding box/sphere
  7011. */
  7012. readonly maximum: Vector3;
  7013. /**
  7014. * If the info is locked and won't be updated to avoid perf overhead
  7015. */
  7016. isLocked: boolean;
  7017. /**
  7018. * Updates the bounding sphere and box
  7019. * @param world world matrix to be used to update
  7020. */
  7021. update(world: DeepImmutable<Matrix>): void;
  7022. /**
  7023. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7024. * @param center New center of the bounding info
  7025. * @param extend New extend of the bounding info
  7026. * @returns the current bounding info
  7027. */
  7028. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7029. /**
  7030. * Scale the current bounding info by applying a scale factor
  7031. * @param factor defines the scale factor to apply
  7032. * @returns the current bounding info
  7033. */
  7034. scale(factor: number): BoundingInfo;
  7035. /**
  7036. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7037. * @param frustumPlanes defines the frustum to test
  7038. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7039. * @returns true if the bounding info is in the frustum planes
  7040. */
  7041. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7042. /**
  7043. * Gets the world distance between the min and max points of the bounding box
  7044. */
  7045. readonly diagonalLength: number;
  7046. /**
  7047. * Checks if a cullable object (mesh...) is in the camera frustum
  7048. * Unlike isInFrustum this cheks the full bounding box
  7049. * @param frustumPlanes Camera near/planes
  7050. * @returns true if the object is in frustum otherwise false
  7051. */
  7052. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7053. /** @hidden */
  7054. _checkCollision(collider: Collider): boolean;
  7055. /**
  7056. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7057. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7058. * @param point the point to check intersection with
  7059. * @returns if the point intersects
  7060. */
  7061. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7062. /**
  7063. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7064. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7065. * @param boundingInfo the bounding info to check intersection with
  7066. * @param precise if the intersection should be done using OBB
  7067. * @returns if the bounding info intersects
  7068. */
  7069. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7070. }
  7071. }
  7072. declare module BABYLON {
  7073. /**
  7074. * Extracts minimum and maximum values from a list of indexed positions
  7075. * @param positions defines the positions to use
  7076. * @param indices defines the indices to the positions
  7077. * @param indexStart defines the start index
  7078. * @param indexCount defines the end index
  7079. * @param bias defines bias value to add to the result
  7080. * @return minimum and maximum values
  7081. */
  7082. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7083. minimum: Vector3;
  7084. maximum: Vector3;
  7085. };
  7086. /**
  7087. * Extracts minimum and maximum values from a list of positions
  7088. * @param positions defines the positions to use
  7089. * @param start defines the start index in the positions array
  7090. * @param count defines the number of positions to handle
  7091. * @param bias defines bias value to add to the result
  7092. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7093. * @return minimum and maximum values
  7094. */
  7095. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7096. minimum: Vector3;
  7097. maximum: Vector3;
  7098. };
  7099. }
  7100. declare module BABYLON {
  7101. /** @hidden */
  7102. export class WebGLDataBuffer extends DataBuffer {
  7103. private _buffer;
  7104. constructor(resource: WebGLBuffer);
  7105. readonly underlyingResource: any;
  7106. }
  7107. }
  7108. declare module BABYLON {
  7109. /** @hidden */
  7110. export class WebGLPipelineContext implements IPipelineContext {
  7111. engine: ThinEngine;
  7112. program: Nullable<WebGLProgram>;
  7113. context?: WebGLRenderingContext;
  7114. vertexShader?: WebGLShader;
  7115. fragmentShader?: WebGLShader;
  7116. isParallelCompiled: boolean;
  7117. onCompiled?: () => void;
  7118. transformFeedback?: WebGLTransformFeedback | null;
  7119. readonly isAsync: boolean;
  7120. readonly isReady: boolean;
  7121. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7122. }
  7123. }
  7124. declare module BABYLON {
  7125. interface ThinEngine {
  7126. /**
  7127. * Create an uniform buffer
  7128. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7129. * @param elements defines the content of the uniform buffer
  7130. * @returns the webGL uniform buffer
  7131. */
  7132. createUniformBuffer(elements: FloatArray): DataBuffer;
  7133. /**
  7134. * Create a dynamic uniform buffer
  7135. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7136. * @param elements defines the content of the uniform buffer
  7137. * @returns the webGL uniform buffer
  7138. */
  7139. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7140. /**
  7141. * Update an existing uniform buffer
  7142. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7143. * @param uniformBuffer defines the target uniform buffer
  7144. * @param elements defines the content to update
  7145. * @param offset defines the offset in the uniform buffer where update should start
  7146. * @param count defines the size of the data to update
  7147. */
  7148. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7149. /**
  7150. * Bind an uniform buffer to the current webGL context
  7151. * @param buffer defines the buffer to bind
  7152. */
  7153. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7154. /**
  7155. * Bind a buffer to the current webGL context at a given location
  7156. * @param buffer defines the buffer to bind
  7157. * @param location defines the index where to bind the buffer
  7158. */
  7159. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7160. /**
  7161. * Bind a specific block at a given index in a specific shader program
  7162. * @param pipelineContext defines the pipeline context to use
  7163. * @param blockName defines the block name
  7164. * @param index defines the index where to bind the block
  7165. */
  7166. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7167. }
  7168. }
  7169. declare module BABYLON {
  7170. /**
  7171. * Uniform buffer objects.
  7172. *
  7173. * Handles blocks of uniform on the GPU.
  7174. *
  7175. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7176. *
  7177. * For more information, please refer to :
  7178. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7179. */
  7180. export class UniformBuffer {
  7181. private _engine;
  7182. private _buffer;
  7183. private _data;
  7184. private _bufferData;
  7185. private _dynamic?;
  7186. private _uniformLocations;
  7187. private _uniformSizes;
  7188. private _uniformLocationPointer;
  7189. private _needSync;
  7190. private _noUBO;
  7191. private _currentEffect;
  7192. private static _MAX_UNIFORM_SIZE;
  7193. private static _tempBuffer;
  7194. /**
  7195. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7196. * This is dynamic to allow compat with webgl 1 and 2.
  7197. * You will need to pass the name of the uniform as well as the value.
  7198. */
  7199. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7200. /**
  7201. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7202. * This is dynamic to allow compat with webgl 1 and 2.
  7203. * You will need to pass the name of the uniform as well as the value.
  7204. */
  7205. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7206. /**
  7207. * Lambda to Update a single float in a uniform buffer.
  7208. * This is dynamic to allow compat with webgl 1 and 2.
  7209. * You will need to pass the name of the uniform as well as the value.
  7210. */
  7211. updateFloat: (name: string, x: number) => void;
  7212. /**
  7213. * Lambda to Update a vec2 of float in a uniform buffer.
  7214. * This is dynamic to allow compat with webgl 1 and 2.
  7215. * You will need to pass the name of the uniform as well as the value.
  7216. */
  7217. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7218. /**
  7219. * Lambda to Update a vec3 of float in a uniform buffer.
  7220. * This is dynamic to allow compat with webgl 1 and 2.
  7221. * You will need to pass the name of the uniform as well as the value.
  7222. */
  7223. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7224. /**
  7225. * Lambda to Update a vec4 of float in a uniform buffer.
  7226. * This is dynamic to allow compat with webgl 1 and 2.
  7227. * You will need to pass the name of the uniform as well as the value.
  7228. */
  7229. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7230. /**
  7231. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7232. * This is dynamic to allow compat with webgl 1 and 2.
  7233. * You will need to pass the name of the uniform as well as the value.
  7234. */
  7235. updateMatrix: (name: string, mat: Matrix) => void;
  7236. /**
  7237. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7238. * This is dynamic to allow compat with webgl 1 and 2.
  7239. * You will need to pass the name of the uniform as well as the value.
  7240. */
  7241. updateVector3: (name: string, vector: Vector3) => void;
  7242. /**
  7243. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7244. * This is dynamic to allow compat with webgl 1 and 2.
  7245. * You will need to pass the name of the uniform as well as the value.
  7246. */
  7247. updateVector4: (name: string, vector: Vector4) => void;
  7248. /**
  7249. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7250. * This is dynamic to allow compat with webgl 1 and 2.
  7251. * You will need to pass the name of the uniform as well as the value.
  7252. */
  7253. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7254. /**
  7255. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7256. * This is dynamic to allow compat with webgl 1 and 2.
  7257. * You will need to pass the name of the uniform as well as the value.
  7258. */
  7259. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7260. /**
  7261. * Instantiates a new Uniform buffer objects.
  7262. *
  7263. * Handles blocks of uniform on the GPU.
  7264. *
  7265. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7266. *
  7267. * For more information, please refer to :
  7268. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7269. * @param engine Define the engine the buffer is associated with
  7270. * @param data Define the data contained in the buffer
  7271. * @param dynamic Define if the buffer is updatable
  7272. */
  7273. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7274. /**
  7275. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7276. * or just falling back on setUniformXXX calls.
  7277. */
  7278. readonly useUbo: boolean;
  7279. /**
  7280. * Indicates if the WebGL underlying uniform buffer is in sync
  7281. * with the javascript cache data.
  7282. */
  7283. readonly isSync: boolean;
  7284. /**
  7285. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7286. * Also, a dynamic UniformBuffer will disable cache verification and always
  7287. * update the underlying WebGL uniform buffer to the GPU.
  7288. * @returns if Dynamic, otherwise false
  7289. */
  7290. isDynamic(): boolean;
  7291. /**
  7292. * The data cache on JS side.
  7293. * @returns the underlying data as a float array
  7294. */
  7295. getData(): Float32Array;
  7296. /**
  7297. * The underlying WebGL Uniform buffer.
  7298. * @returns the webgl buffer
  7299. */
  7300. getBuffer(): Nullable<DataBuffer>;
  7301. /**
  7302. * std140 layout specifies how to align data within an UBO structure.
  7303. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7304. * for specs.
  7305. */
  7306. private _fillAlignment;
  7307. /**
  7308. * Adds an uniform in the buffer.
  7309. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7310. * for the layout to be correct !
  7311. * @param name Name of the uniform, as used in the uniform block in the shader.
  7312. * @param size Data size, or data directly.
  7313. */
  7314. addUniform(name: string, size: number | number[]): void;
  7315. /**
  7316. * Adds a Matrix 4x4 to the uniform buffer.
  7317. * @param name Name of the uniform, as used in the uniform block in the shader.
  7318. * @param mat A 4x4 matrix.
  7319. */
  7320. addMatrix(name: string, mat: Matrix): void;
  7321. /**
  7322. * Adds a vec2 to the uniform buffer.
  7323. * @param name Name of the uniform, as used in the uniform block in the shader.
  7324. * @param x Define the x component value of the vec2
  7325. * @param y Define the y component value of the vec2
  7326. */
  7327. addFloat2(name: string, x: number, y: number): void;
  7328. /**
  7329. * Adds a vec3 to the uniform buffer.
  7330. * @param name Name of the uniform, as used in the uniform block in the shader.
  7331. * @param x Define the x component value of the vec3
  7332. * @param y Define the y component value of the vec3
  7333. * @param z Define the z component value of the vec3
  7334. */
  7335. addFloat3(name: string, x: number, y: number, z: number): void;
  7336. /**
  7337. * Adds a vec3 to the uniform buffer.
  7338. * @param name Name of the uniform, as used in the uniform block in the shader.
  7339. * @param color Define the vec3 from a Color
  7340. */
  7341. addColor3(name: string, color: Color3): void;
  7342. /**
  7343. * Adds a vec4 to the uniform buffer.
  7344. * @param name Name of the uniform, as used in the uniform block in the shader.
  7345. * @param color Define the rgb components from a Color
  7346. * @param alpha Define the a component of the vec4
  7347. */
  7348. addColor4(name: string, color: Color3, alpha: number): void;
  7349. /**
  7350. * Adds a vec3 to the uniform buffer.
  7351. * @param name Name of the uniform, as used in the uniform block in the shader.
  7352. * @param vector Define the vec3 components from a Vector
  7353. */
  7354. addVector3(name: string, vector: Vector3): void;
  7355. /**
  7356. * Adds a Matrix 3x3 to the uniform buffer.
  7357. * @param name Name of the uniform, as used in the uniform block in the shader.
  7358. */
  7359. addMatrix3x3(name: string): void;
  7360. /**
  7361. * Adds a Matrix 2x2 to the uniform buffer.
  7362. * @param name Name of the uniform, as used in the uniform block in the shader.
  7363. */
  7364. addMatrix2x2(name: string): void;
  7365. /**
  7366. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7367. */
  7368. create(): void;
  7369. /** @hidden */
  7370. _rebuild(): void;
  7371. /**
  7372. * Updates the WebGL Uniform Buffer on the GPU.
  7373. * If the `dynamic` flag is set to true, no cache comparison is done.
  7374. * Otherwise, the buffer will be updated only if the cache differs.
  7375. */
  7376. update(): void;
  7377. /**
  7378. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7379. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7380. * @param data Define the flattened data
  7381. * @param size Define the size of the data.
  7382. */
  7383. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7384. private _valueCache;
  7385. private _cacheMatrix;
  7386. private _updateMatrix3x3ForUniform;
  7387. private _updateMatrix3x3ForEffect;
  7388. private _updateMatrix2x2ForEffect;
  7389. private _updateMatrix2x2ForUniform;
  7390. private _updateFloatForEffect;
  7391. private _updateFloatForUniform;
  7392. private _updateFloat2ForEffect;
  7393. private _updateFloat2ForUniform;
  7394. private _updateFloat3ForEffect;
  7395. private _updateFloat3ForUniform;
  7396. private _updateFloat4ForEffect;
  7397. private _updateFloat4ForUniform;
  7398. private _updateMatrixForEffect;
  7399. private _updateMatrixForUniform;
  7400. private _updateVector3ForEffect;
  7401. private _updateVector3ForUniform;
  7402. private _updateVector4ForEffect;
  7403. private _updateVector4ForUniform;
  7404. private _updateColor3ForEffect;
  7405. private _updateColor3ForUniform;
  7406. private _updateColor4ForEffect;
  7407. private _updateColor4ForUniform;
  7408. /**
  7409. * Sets a sampler uniform on the effect.
  7410. * @param name Define the name of the sampler.
  7411. * @param texture Define the texture to set in the sampler
  7412. */
  7413. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7414. /**
  7415. * Directly updates the value of the uniform in the cache AND on the GPU.
  7416. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7417. * @param data Define the flattened data
  7418. */
  7419. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7420. /**
  7421. * Binds this uniform buffer to an effect.
  7422. * @param effect Define the effect to bind the buffer to
  7423. * @param name Name of the uniform block in the shader.
  7424. */
  7425. bindToEffect(effect: Effect, name: string): void;
  7426. /**
  7427. * Disposes the uniform buffer.
  7428. */
  7429. dispose(): void;
  7430. }
  7431. }
  7432. declare module BABYLON {
  7433. /**
  7434. * Enum that determines the text-wrapping mode to use.
  7435. */
  7436. export enum InspectableType {
  7437. /**
  7438. * Checkbox for booleans
  7439. */
  7440. Checkbox = 0,
  7441. /**
  7442. * Sliders for numbers
  7443. */
  7444. Slider = 1,
  7445. /**
  7446. * Vector3
  7447. */
  7448. Vector3 = 2,
  7449. /**
  7450. * Quaternions
  7451. */
  7452. Quaternion = 3,
  7453. /**
  7454. * Color3
  7455. */
  7456. Color3 = 4,
  7457. /**
  7458. * String
  7459. */
  7460. String = 5
  7461. }
  7462. /**
  7463. * Interface used to define custom inspectable properties.
  7464. * This interface is used by the inspector to display custom property grids
  7465. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7466. */
  7467. export interface IInspectable {
  7468. /**
  7469. * Gets the label to display
  7470. */
  7471. label: string;
  7472. /**
  7473. * Gets the name of the property to edit
  7474. */
  7475. propertyName: string;
  7476. /**
  7477. * Gets the type of the editor to use
  7478. */
  7479. type: InspectableType;
  7480. /**
  7481. * Gets the minimum value of the property when using in "slider" mode
  7482. */
  7483. min?: number;
  7484. /**
  7485. * Gets the maximum value of the property when using in "slider" mode
  7486. */
  7487. max?: number;
  7488. /**
  7489. * Gets the setp to use when using in "slider" mode
  7490. */
  7491. step?: number;
  7492. }
  7493. }
  7494. declare module BABYLON {
  7495. /**
  7496. * Class used to provide helper for timing
  7497. */
  7498. export class TimingTools {
  7499. /**
  7500. * Polyfill for setImmediate
  7501. * @param action defines the action to execute after the current execution block
  7502. */
  7503. static SetImmediate(action: () => void): void;
  7504. }
  7505. }
  7506. declare module BABYLON {
  7507. /**
  7508. * Class used to enable instatition of objects by class name
  7509. */
  7510. export class InstantiationTools {
  7511. /**
  7512. * Use this object to register external classes like custom textures or material
  7513. * to allow the laoders to instantiate them
  7514. */
  7515. static RegisteredExternalClasses: {
  7516. [key: string]: Object;
  7517. };
  7518. /**
  7519. * Tries to instantiate a new object from a given class name
  7520. * @param className defines the class name to instantiate
  7521. * @returns the new object or null if the system was not able to do the instantiation
  7522. */
  7523. static Instantiate(className: string): any;
  7524. }
  7525. }
  7526. declare module BABYLON {
  7527. /**
  7528. * Define options used to create a depth texture
  7529. */
  7530. export class DepthTextureCreationOptions {
  7531. /** Specifies whether or not a stencil should be allocated in the texture */
  7532. generateStencil?: boolean;
  7533. /** Specifies whether or not bilinear filtering is enable on the texture */
  7534. bilinearFiltering?: boolean;
  7535. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7536. comparisonFunction?: number;
  7537. /** Specifies if the created texture is a cube texture */
  7538. isCube?: boolean;
  7539. }
  7540. }
  7541. declare module BABYLON {
  7542. interface ThinEngine {
  7543. /**
  7544. * Creates a depth stencil cube texture.
  7545. * This is only available in WebGL 2.
  7546. * @param size The size of face edge in the cube texture.
  7547. * @param options The options defining the cube texture.
  7548. * @returns The cube texture
  7549. */
  7550. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7551. /**
  7552. * Creates a cube texture
  7553. * @param rootUrl defines the url where the files to load is located
  7554. * @param scene defines the current scene
  7555. * @param files defines the list of files to load (1 per face)
  7556. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7557. * @param onLoad defines an optional callback raised when the texture is loaded
  7558. * @param onError defines an optional callback raised if there is an issue to load the texture
  7559. * @param format defines the format of the data
  7560. * @param forcedExtension defines the extension to use to pick the right loader
  7561. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7562. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7563. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7564. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7565. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7566. * @returns the cube texture as an InternalTexture
  7567. */
  7568. 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;
  7569. /**
  7570. * Creates a cube texture
  7571. * @param rootUrl defines the url where the files to load is located
  7572. * @param scene defines the current scene
  7573. * @param files defines the list of files to load (1 per face)
  7574. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7575. * @param onLoad defines an optional callback raised when the texture is loaded
  7576. * @param onError defines an optional callback raised if there is an issue to load the texture
  7577. * @param format defines the format of the data
  7578. * @param forcedExtension defines the extension to use to pick the right loader
  7579. * @returns the cube texture as an InternalTexture
  7580. */
  7581. 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;
  7582. /**
  7583. * Creates a cube texture
  7584. * @param rootUrl defines the url where the files to load is located
  7585. * @param scene defines the current scene
  7586. * @param files defines the list of files to load (1 per face)
  7587. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7588. * @param onLoad defines an optional callback raised when the texture is loaded
  7589. * @param onError defines an optional callback raised if there is an issue to load the texture
  7590. * @param format defines the format of the data
  7591. * @param forcedExtension defines the extension to use to pick the right loader
  7592. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7593. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7594. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7595. * @returns the cube texture as an InternalTexture
  7596. */
  7597. 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;
  7598. /** @hidden */
  7599. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7600. /** @hidden */
  7601. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7602. /** @hidden */
  7603. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7604. /** @hidden */
  7605. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7606. }
  7607. }
  7608. declare module BABYLON {
  7609. /**
  7610. * Class for creating a cube texture
  7611. */
  7612. export class CubeTexture extends BaseTexture {
  7613. private _delayedOnLoad;
  7614. /**
  7615. * The url of the texture
  7616. */
  7617. url: string;
  7618. /**
  7619. * Gets or sets the center of the bounding box associated with the cube texture.
  7620. * It must define where the camera used to render the texture was set
  7621. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7622. */
  7623. boundingBoxPosition: Vector3;
  7624. private _boundingBoxSize;
  7625. /**
  7626. * Gets or sets the size of the bounding box associated with the cube texture
  7627. * When defined, the cubemap will switch to local mode
  7628. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7629. * @example https://www.babylonjs-playground.com/#RNASML
  7630. */
  7631. /**
  7632. * Returns the bounding box size
  7633. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7634. */
  7635. boundingBoxSize: Vector3;
  7636. protected _rotationY: number;
  7637. /**
  7638. * Sets texture matrix rotation angle around Y axis in radians.
  7639. */
  7640. /**
  7641. * Gets texture matrix rotation angle around Y axis radians.
  7642. */
  7643. rotationY: number;
  7644. /**
  7645. * Are mip maps generated for this texture or not.
  7646. */
  7647. readonly noMipmap: boolean;
  7648. private _noMipmap;
  7649. private _files;
  7650. protected _forcedExtension: Nullable<string>;
  7651. private _extensions;
  7652. private _textureMatrix;
  7653. private _format;
  7654. private _createPolynomials;
  7655. /** @hidden */
  7656. _prefiltered: boolean;
  7657. /**
  7658. * Creates a cube texture from an array of image urls
  7659. * @param files defines an array of image urls
  7660. * @param scene defines the hosting scene
  7661. * @param noMipmap specifies if mip maps are not used
  7662. * @returns a cube texture
  7663. */
  7664. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7665. /**
  7666. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7667. * @param url defines the url of the prefiltered texture
  7668. * @param scene defines the scene the texture is attached to
  7669. * @param forcedExtension defines the extension of the file if different from the url
  7670. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7671. * @return the prefiltered texture
  7672. */
  7673. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7674. /**
  7675. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7676. * as prefiltered data.
  7677. * @param rootUrl defines the url of the texture or the root name of the six images
  7678. * @param scene defines the scene the texture is attached to
  7679. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7680. * @param noMipmap defines if mipmaps should be created or not
  7681. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7682. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7683. * @param onError defines a callback triggered in case of error during load
  7684. * @param format defines the internal format to use for the texture once loaded
  7685. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7686. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7687. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7688. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7689. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7690. * @return the cube texture
  7691. */
  7692. 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);
  7693. /**
  7694. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7695. */
  7696. readonly isPrefiltered: boolean;
  7697. /**
  7698. * Get the current class name of the texture useful for serialization or dynamic coding.
  7699. * @returns "CubeTexture"
  7700. */
  7701. getClassName(): string;
  7702. /**
  7703. * Update the url (and optional buffer) of this texture if url was null during construction.
  7704. * @param url the url of the texture
  7705. * @param forcedExtension defines the extension to use
  7706. * @param onLoad callback called when the texture is loaded (defaults to null)
  7707. */
  7708. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7709. /**
  7710. * Delays loading of the cube texture
  7711. * @param forcedExtension defines the extension to use
  7712. */
  7713. delayLoad(forcedExtension?: string): void;
  7714. /**
  7715. * Returns the reflection texture matrix
  7716. * @returns the reflection texture matrix
  7717. */
  7718. getReflectionTextureMatrix(): Matrix;
  7719. /**
  7720. * Sets the reflection texture matrix
  7721. * @param value Reflection texture matrix
  7722. */
  7723. setReflectionTextureMatrix(value: Matrix): void;
  7724. /**
  7725. * Parses text to create a cube texture
  7726. * @param parsedTexture define the serialized text to read from
  7727. * @param scene defines the hosting scene
  7728. * @param rootUrl defines the root url of the cube texture
  7729. * @returns a cube texture
  7730. */
  7731. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7732. /**
  7733. * Makes a clone, or deep copy, of the cube texture
  7734. * @returns a new cube texture
  7735. */
  7736. clone(): CubeTexture;
  7737. }
  7738. }
  7739. declare module BABYLON {
  7740. /**
  7741. * Manages the defines for the Material
  7742. */
  7743. export class MaterialDefines {
  7744. /** @hidden */
  7745. protected _keys: string[];
  7746. private _isDirty;
  7747. /** @hidden */
  7748. _renderId: number;
  7749. /** @hidden */
  7750. _areLightsDirty: boolean;
  7751. /** @hidden */
  7752. _areLightsDisposed: boolean;
  7753. /** @hidden */
  7754. _areAttributesDirty: boolean;
  7755. /** @hidden */
  7756. _areTexturesDirty: boolean;
  7757. /** @hidden */
  7758. _areFresnelDirty: boolean;
  7759. /** @hidden */
  7760. _areMiscDirty: boolean;
  7761. /** @hidden */
  7762. _areImageProcessingDirty: boolean;
  7763. /** @hidden */
  7764. _normals: boolean;
  7765. /** @hidden */
  7766. _uvs: boolean;
  7767. /** @hidden */
  7768. _needNormals: boolean;
  7769. /** @hidden */
  7770. _needUVs: boolean;
  7771. [id: string]: any;
  7772. /**
  7773. * Specifies if the material needs to be re-calculated
  7774. */
  7775. readonly isDirty: boolean;
  7776. /**
  7777. * Marks the material to indicate that it has been re-calculated
  7778. */
  7779. markAsProcessed(): void;
  7780. /**
  7781. * Marks the material to indicate that it needs to be re-calculated
  7782. */
  7783. markAsUnprocessed(): void;
  7784. /**
  7785. * Marks the material to indicate all of its defines need to be re-calculated
  7786. */
  7787. markAllAsDirty(): void;
  7788. /**
  7789. * Marks the material to indicate that image processing needs to be re-calculated
  7790. */
  7791. markAsImageProcessingDirty(): void;
  7792. /**
  7793. * Marks the material to indicate the lights need to be re-calculated
  7794. * @param disposed Defines whether the light is dirty due to dispose or not
  7795. */
  7796. markAsLightDirty(disposed?: boolean): void;
  7797. /**
  7798. * Marks the attribute state as changed
  7799. */
  7800. markAsAttributesDirty(): void;
  7801. /**
  7802. * Marks the texture state as changed
  7803. */
  7804. markAsTexturesDirty(): void;
  7805. /**
  7806. * Marks the fresnel state as changed
  7807. */
  7808. markAsFresnelDirty(): void;
  7809. /**
  7810. * Marks the misc state as changed
  7811. */
  7812. markAsMiscDirty(): void;
  7813. /**
  7814. * Rebuilds the material defines
  7815. */
  7816. rebuild(): void;
  7817. /**
  7818. * Specifies if two material defines are equal
  7819. * @param other - A material define instance to compare to
  7820. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7821. */
  7822. isEqual(other: MaterialDefines): boolean;
  7823. /**
  7824. * Clones this instance's defines to another instance
  7825. * @param other - material defines to clone values to
  7826. */
  7827. cloneTo(other: MaterialDefines): void;
  7828. /**
  7829. * Resets the material define values
  7830. */
  7831. reset(): void;
  7832. /**
  7833. * Converts the material define values to a string
  7834. * @returns - String of material define information
  7835. */
  7836. toString(): string;
  7837. }
  7838. }
  7839. declare module BABYLON {
  7840. /**
  7841. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7842. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7843. * 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;
  7844. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7845. */
  7846. export class ColorCurves {
  7847. private _dirty;
  7848. private _tempColor;
  7849. private _globalCurve;
  7850. private _highlightsCurve;
  7851. private _midtonesCurve;
  7852. private _shadowsCurve;
  7853. private _positiveCurve;
  7854. private _negativeCurve;
  7855. private _globalHue;
  7856. private _globalDensity;
  7857. private _globalSaturation;
  7858. private _globalExposure;
  7859. /**
  7860. * Gets the global Hue value.
  7861. * 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).
  7862. */
  7863. /**
  7864. * Sets the global Hue value.
  7865. * 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).
  7866. */
  7867. globalHue: number;
  7868. /**
  7869. * Gets the global Density value.
  7870. * 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.
  7871. * Values less than zero provide a filter of opposite hue.
  7872. */
  7873. /**
  7874. * Sets the global Density value.
  7875. * 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.
  7876. * Values less than zero provide a filter of opposite hue.
  7877. */
  7878. globalDensity: number;
  7879. /**
  7880. * Gets the global Saturation value.
  7881. * 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.
  7882. */
  7883. /**
  7884. * Sets the global Saturation value.
  7885. * 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.
  7886. */
  7887. globalSaturation: number;
  7888. /**
  7889. * Gets the global Exposure value.
  7890. * 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.
  7891. */
  7892. /**
  7893. * Sets the global Exposure value.
  7894. * 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.
  7895. */
  7896. globalExposure: number;
  7897. private _highlightsHue;
  7898. private _highlightsDensity;
  7899. private _highlightsSaturation;
  7900. private _highlightsExposure;
  7901. /**
  7902. * Gets the highlights Hue value.
  7903. * 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).
  7904. */
  7905. /**
  7906. * Sets the highlights Hue value.
  7907. * 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).
  7908. */
  7909. highlightsHue: number;
  7910. /**
  7911. * Gets the highlights Density value.
  7912. * 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.
  7913. * Values less than zero provide a filter of opposite hue.
  7914. */
  7915. /**
  7916. * Sets the highlights Density value.
  7917. * 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.
  7918. * Values less than zero provide a filter of opposite hue.
  7919. */
  7920. highlightsDensity: number;
  7921. /**
  7922. * Gets the highlights Saturation value.
  7923. * 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.
  7924. */
  7925. /**
  7926. * Sets the highlights Saturation value.
  7927. * 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.
  7928. */
  7929. highlightsSaturation: number;
  7930. /**
  7931. * Gets the highlights Exposure value.
  7932. * 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.
  7933. */
  7934. /**
  7935. * Sets the highlights Exposure value.
  7936. * 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.
  7937. */
  7938. highlightsExposure: number;
  7939. private _midtonesHue;
  7940. private _midtonesDensity;
  7941. private _midtonesSaturation;
  7942. private _midtonesExposure;
  7943. /**
  7944. * Gets the midtones Hue value.
  7945. * 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).
  7946. */
  7947. /**
  7948. * Sets the midtones Hue value.
  7949. * 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).
  7950. */
  7951. midtonesHue: number;
  7952. /**
  7953. * Gets the midtones Density value.
  7954. * 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.
  7955. * Values less than zero provide a filter of opposite hue.
  7956. */
  7957. /**
  7958. * Sets the midtones Density value.
  7959. * 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.
  7960. * Values less than zero provide a filter of opposite hue.
  7961. */
  7962. midtonesDensity: number;
  7963. /**
  7964. * Gets the midtones Saturation value.
  7965. * 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.
  7966. */
  7967. /**
  7968. * Sets the midtones Saturation value.
  7969. * 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.
  7970. */
  7971. midtonesSaturation: number;
  7972. /**
  7973. * Gets the midtones Exposure value.
  7974. * 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.
  7975. */
  7976. /**
  7977. * Sets the midtones Exposure value.
  7978. * 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.
  7979. */
  7980. midtonesExposure: number;
  7981. private _shadowsHue;
  7982. private _shadowsDensity;
  7983. private _shadowsSaturation;
  7984. private _shadowsExposure;
  7985. /**
  7986. * Gets the shadows Hue value.
  7987. * 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).
  7988. */
  7989. /**
  7990. * Sets the shadows Hue value.
  7991. * 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).
  7992. */
  7993. shadowsHue: number;
  7994. /**
  7995. * Gets the shadows Density value.
  7996. * 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.
  7997. * Values less than zero provide a filter of opposite hue.
  7998. */
  7999. /**
  8000. * Sets the shadows Density value.
  8001. * 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.
  8002. * Values less than zero provide a filter of opposite hue.
  8003. */
  8004. shadowsDensity: number;
  8005. /**
  8006. * Gets the shadows Saturation value.
  8007. * 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.
  8008. */
  8009. /**
  8010. * Sets the shadows Saturation value.
  8011. * 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.
  8012. */
  8013. shadowsSaturation: number;
  8014. /**
  8015. * Gets the shadows Exposure value.
  8016. * 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.
  8017. */
  8018. /**
  8019. * Sets the shadows Exposure value.
  8020. * 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.
  8021. */
  8022. shadowsExposure: number;
  8023. /**
  8024. * Returns the class name
  8025. * @returns The class name
  8026. */
  8027. getClassName(): string;
  8028. /**
  8029. * Binds the color curves to the shader.
  8030. * @param colorCurves The color curve to bind
  8031. * @param effect The effect to bind to
  8032. * @param positiveUniform The positive uniform shader parameter
  8033. * @param neutralUniform The neutral uniform shader parameter
  8034. * @param negativeUniform The negative uniform shader parameter
  8035. */
  8036. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8037. /**
  8038. * Prepare the list of uniforms associated with the ColorCurves effects.
  8039. * @param uniformsList The list of uniforms used in the effect
  8040. */
  8041. static PrepareUniforms(uniformsList: string[]): void;
  8042. /**
  8043. * Returns color grading data based on a hue, density, saturation and exposure value.
  8044. * @param filterHue The hue of the color filter.
  8045. * @param filterDensity The density of the color filter.
  8046. * @param saturation The saturation.
  8047. * @param exposure The exposure.
  8048. * @param result The result data container.
  8049. */
  8050. private getColorGradingDataToRef;
  8051. /**
  8052. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8053. * @param value The input slider value in range [-100,100].
  8054. * @returns Adjusted value.
  8055. */
  8056. private static applyColorGradingSliderNonlinear;
  8057. /**
  8058. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8059. * @param hue The hue (H) input.
  8060. * @param saturation The saturation (S) input.
  8061. * @param brightness The brightness (B) input.
  8062. * @result An RGBA color represented as Vector4.
  8063. */
  8064. private static fromHSBToRef;
  8065. /**
  8066. * Returns a value clamped between min and max
  8067. * @param value The value to clamp
  8068. * @param min The minimum of value
  8069. * @param max The maximum of value
  8070. * @returns The clamped value.
  8071. */
  8072. private static clamp;
  8073. /**
  8074. * Clones the current color curve instance.
  8075. * @return The cloned curves
  8076. */
  8077. clone(): ColorCurves;
  8078. /**
  8079. * Serializes the current color curve instance to a json representation.
  8080. * @return a JSON representation
  8081. */
  8082. serialize(): any;
  8083. /**
  8084. * Parses the color curve from a json representation.
  8085. * @param source the JSON source to parse
  8086. * @return The parsed curves
  8087. */
  8088. static Parse(source: any): ColorCurves;
  8089. }
  8090. }
  8091. declare module BABYLON {
  8092. /**
  8093. * Interface to follow in your material defines to integrate easily the
  8094. * Image proccessing functions.
  8095. * @hidden
  8096. */
  8097. export interface IImageProcessingConfigurationDefines {
  8098. IMAGEPROCESSING: boolean;
  8099. VIGNETTE: boolean;
  8100. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8101. VIGNETTEBLENDMODEOPAQUE: boolean;
  8102. TONEMAPPING: boolean;
  8103. TONEMAPPING_ACES: boolean;
  8104. CONTRAST: boolean;
  8105. EXPOSURE: boolean;
  8106. COLORCURVES: boolean;
  8107. COLORGRADING: boolean;
  8108. COLORGRADING3D: boolean;
  8109. SAMPLER3DGREENDEPTH: boolean;
  8110. SAMPLER3DBGRMAP: boolean;
  8111. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8112. }
  8113. /**
  8114. * @hidden
  8115. */
  8116. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8117. IMAGEPROCESSING: boolean;
  8118. VIGNETTE: boolean;
  8119. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8120. VIGNETTEBLENDMODEOPAQUE: boolean;
  8121. TONEMAPPING: boolean;
  8122. TONEMAPPING_ACES: boolean;
  8123. CONTRAST: boolean;
  8124. COLORCURVES: boolean;
  8125. COLORGRADING: boolean;
  8126. COLORGRADING3D: boolean;
  8127. SAMPLER3DGREENDEPTH: boolean;
  8128. SAMPLER3DBGRMAP: boolean;
  8129. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8130. EXPOSURE: boolean;
  8131. constructor();
  8132. }
  8133. /**
  8134. * This groups together the common properties used for image processing either in direct forward pass
  8135. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8136. * or not.
  8137. */
  8138. export class ImageProcessingConfiguration {
  8139. /**
  8140. * Default tone mapping applied in BabylonJS.
  8141. */
  8142. static readonly TONEMAPPING_STANDARD: number;
  8143. /**
  8144. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8145. * to other engines rendering to increase portability.
  8146. */
  8147. static readonly TONEMAPPING_ACES: number;
  8148. /**
  8149. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8150. */
  8151. colorCurves: Nullable<ColorCurves>;
  8152. private _colorCurvesEnabled;
  8153. /**
  8154. * Gets wether the color curves effect is enabled.
  8155. */
  8156. /**
  8157. * Sets wether the color curves effect is enabled.
  8158. */
  8159. colorCurvesEnabled: boolean;
  8160. private _colorGradingTexture;
  8161. /**
  8162. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8163. */
  8164. /**
  8165. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8166. */
  8167. colorGradingTexture: Nullable<BaseTexture>;
  8168. private _colorGradingEnabled;
  8169. /**
  8170. * Gets wether the color grading effect is enabled.
  8171. */
  8172. /**
  8173. * Sets wether the color grading effect is enabled.
  8174. */
  8175. colorGradingEnabled: boolean;
  8176. private _colorGradingWithGreenDepth;
  8177. /**
  8178. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8179. */
  8180. /**
  8181. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8182. */
  8183. colorGradingWithGreenDepth: boolean;
  8184. private _colorGradingBGR;
  8185. /**
  8186. * Gets wether the color grading texture contains BGR values.
  8187. */
  8188. /**
  8189. * Sets wether the color grading texture contains BGR values.
  8190. */
  8191. colorGradingBGR: boolean;
  8192. /** @hidden */
  8193. _exposure: number;
  8194. /**
  8195. * Gets the Exposure used in the effect.
  8196. */
  8197. /**
  8198. * Sets the Exposure used in the effect.
  8199. */
  8200. exposure: number;
  8201. private _toneMappingEnabled;
  8202. /**
  8203. * Gets wether the tone mapping effect is enabled.
  8204. */
  8205. /**
  8206. * Sets wether the tone mapping effect is enabled.
  8207. */
  8208. toneMappingEnabled: boolean;
  8209. private _toneMappingType;
  8210. /**
  8211. * Gets the type of tone mapping effect.
  8212. */
  8213. /**
  8214. * Sets the type of tone mapping effect used in BabylonJS.
  8215. */
  8216. toneMappingType: number;
  8217. protected _contrast: number;
  8218. /**
  8219. * Gets the contrast used in the effect.
  8220. */
  8221. /**
  8222. * Sets the contrast used in the effect.
  8223. */
  8224. contrast: number;
  8225. /**
  8226. * Vignette stretch size.
  8227. */
  8228. vignetteStretch: number;
  8229. /**
  8230. * Vignette centre X Offset.
  8231. */
  8232. vignetteCentreX: number;
  8233. /**
  8234. * Vignette centre Y Offset.
  8235. */
  8236. vignetteCentreY: number;
  8237. /**
  8238. * Vignette weight or intensity of the vignette effect.
  8239. */
  8240. vignetteWeight: number;
  8241. /**
  8242. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8243. * if vignetteEnabled is set to true.
  8244. */
  8245. vignetteColor: Color4;
  8246. /**
  8247. * Camera field of view used by the Vignette effect.
  8248. */
  8249. vignetteCameraFov: number;
  8250. private _vignetteBlendMode;
  8251. /**
  8252. * Gets the vignette blend mode allowing different kind of effect.
  8253. */
  8254. /**
  8255. * Sets the vignette blend mode allowing different kind of effect.
  8256. */
  8257. vignetteBlendMode: number;
  8258. private _vignetteEnabled;
  8259. /**
  8260. * Gets wether the vignette effect is enabled.
  8261. */
  8262. /**
  8263. * Sets wether the vignette effect is enabled.
  8264. */
  8265. vignetteEnabled: boolean;
  8266. private _applyByPostProcess;
  8267. /**
  8268. * Gets wether the image processing is applied through a post process or not.
  8269. */
  8270. /**
  8271. * Sets wether the image processing is applied through a post process or not.
  8272. */
  8273. applyByPostProcess: boolean;
  8274. private _isEnabled;
  8275. /**
  8276. * Gets wether the image processing is enabled or not.
  8277. */
  8278. /**
  8279. * Sets wether the image processing is enabled or not.
  8280. */
  8281. isEnabled: boolean;
  8282. /**
  8283. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8284. */
  8285. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8286. /**
  8287. * Method called each time the image processing information changes requires to recompile the effect.
  8288. */
  8289. protected _updateParameters(): void;
  8290. /**
  8291. * Gets the current class name.
  8292. * @return "ImageProcessingConfiguration"
  8293. */
  8294. getClassName(): string;
  8295. /**
  8296. * Prepare the list of uniforms associated with the Image Processing effects.
  8297. * @param uniforms The list of uniforms used in the effect
  8298. * @param defines the list of defines currently in use
  8299. */
  8300. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8301. /**
  8302. * Prepare the list of samplers associated with the Image Processing effects.
  8303. * @param samplersList The list of uniforms used in the effect
  8304. * @param defines the list of defines currently in use
  8305. */
  8306. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8307. /**
  8308. * Prepare the list of defines associated to the shader.
  8309. * @param defines the list of defines to complete
  8310. * @param forPostProcess Define if we are currently in post process mode or not
  8311. */
  8312. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8313. /**
  8314. * Returns true if all the image processing information are ready.
  8315. * @returns True if ready, otherwise, false
  8316. */
  8317. isReady(): boolean;
  8318. /**
  8319. * Binds the image processing to the shader.
  8320. * @param effect The effect to bind to
  8321. * @param aspectRatio Define the current aspect ratio of the effect
  8322. */
  8323. bind(effect: Effect, aspectRatio?: number): void;
  8324. /**
  8325. * Clones the current image processing instance.
  8326. * @return The cloned image processing
  8327. */
  8328. clone(): ImageProcessingConfiguration;
  8329. /**
  8330. * Serializes the current image processing instance to a json representation.
  8331. * @return a JSON representation
  8332. */
  8333. serialize(): any;
  8334. /**
  8335. * Parses the image processing from a json representation.
  8336. * @param source the JSON source to parse
  8337. * @return The parsed image processing
  8338. */
  8339. static Parse(source: any): ImageProcessingConfiguration;
  8340. private static _VIGNETTEMODE_MULTIPLY;
  8341. private static _VIGNETTEMODE_OPAQUE;
  8342. /**
  8343. * Used to apply the vignette as a mix with the pixel color.
  8344. */
  8345. static readonly VIGNETTEMODE_MULTIPLY: number;
  8346. /**
  8347. * Used to apply the vignette as a replacement of the pixel color.
  8348. */
  8349. static readonly VIGNETTEMODE_OPAQUE: number;
  8350. }
  8351. }
  8352. declare module BABYLON {
  8353. /** @hidden */
  8354. export var postprocessVertexShader: {
  8355. name: string;
  8356. shader: string;
  8357. };
  8358. }
  8359. declare module BABYLON {
  8360. /** Defines supported spaces */
  8361. export enum Space {
  8362. /** Local (object) space */
  8363. LOCAL = 0,
  8364. /** World space */
  8365. WORLD = 1,
  8366. /** Bone space */
  8367. BONE = 2
  8368. }
  8369. /** Defines the 3 main axes */
  8370. export class Axis {
  8371. /** X axis */
  8372. static X: Vector3;
  8373. /** Y axis */
  8374. static Y: Vector3;
  8375. /** Z axis */
  8376. static Z: Vector3;
  8377. }
  8378. }
  8379. declare module BABYLON {
  8380. /**
  8381. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8382. * This is the base of the follow, arc rotate cameras and Free camera
  8383. * @see http://doc.babylonjs.com/features/cameras
  8384. */
  8385. export class TargetCamera extends Camera {
  8386. private static _RigCamTransformMatrix;
  8387. private static _TargetTransformMatrix;
  8388. private static _TargetFocalPoint;
  8389. /**
  8390. * Define the current direction the camera is moving to
  8391. */
  8392. cameraDirection: Vector3;
  8393. /**
  8394. * Define the current rotation the camera is rotating to
  8395. */
  8396. cameraRotation: Vector2;
  8397. /**
  8398. * When set, the up vector of the camera will be updated by the rotation of the camera
  8399. */
  8400. updateUpVectorFromRotation: boolean;
  8401. private _tmpQuaternion;
  8402. /**
  8403. * Define the current rotation of the camera
  8404. */
  8405. rotation: Vector3;
  8406. /**
  8407. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8408. */
  8409. rotationQuaternion: Quaternion;
  8410. /**
  8411. * Define the current speed of the camera
  8412. */
  8413. speed: number;
  8414. /**
  8415. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8416. * around all axis.
  8417. */
  8418. noRotationConstraint: boolean;
  8419. /**
  8420. * Define the current target of the camera as an object or a position.
  8421. */
  8422. lockedTarget: any;
  8423. /** @hidden */
  8424. _currentTarget: Vector3;
  8425. /** @hidden */
  8426. _initialFocalDistance: number;
  8427. /** @hidden */
  8428. _viewMatrix: Matrix;
  8429. /** @hidden */
  8430. _camMatrix: Matrix;
  8431. /** @hidden */
  8432. _cameraTransformMatrix: Matrix;
  8433. /** @hidden */
  8434. _cameraRotationMatrix: Matrix;
  8435. /** @hidden */
  8436. _referencePoint: Vector3;
  8437. /** @hidden */
  8438. _transformedReferencePoint: Vector3;
  8439. protected _globalCurrentTarget: Vector3;
  8440. protected _globalCurrentUpVector: Vector3;
  8441. /** @hidden */
  8442. _reset: () => void;
  8443. private _defaultUp;
  8444. /**
  8445. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8446. * This is the base of the follow, arc rotate cameras and Free camera
  8447. * @see http://doc.babylonjs.com/features/cameras
  8448. * @param name Defines the name of the camera in the scene
  8449. * @param position Defines the start position of the camera in the scene
  8450. * @param scene Defines the scene the camera belongs to
  8451. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8452. */
  8453. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8454. /**
  8455. * Gets the position in front of the camera at a given distance.
  8456. * @param distance The distance from the camera we want the position to be
  8457. * @returns the position
  8458. */
  8459. getFrontPosition(distance: number): Vector3;
  8460. /** @hidden */
  8461. _getLockedTargetPosition(): Nullable<Vector3>;
  8462. private _storedPosition;
  8463. private _storedRotation;
  8464. private _storedRotationQuaternion;
  8465. /**
  8466. * Store current camera state of the camera (fov, position, rotation, etc..)
  8467. * @returns the camera
  8468. */
  8469. storeState(): Camera;
  8470. /**
  8471. * Restored camera state. You must call storeState() first
  8472. * @returns whether it was successful or not
  8473. * @hidden
  8474. */
  8475. _restoreStateValues(): boolean;
  8476. /** @hidden */
  8477. _initCache(): void;
  8478. /** @hidden */
  8479. _updateCache(ignoreParentClass?: boolean): void;
  8480. /** @hidden */
  8481. _isSynchronizedViewMatrix(): boolean;
  8482. /** @hidden */
  8483. _computeLocalCameraSpeed(): number;
  8484. /**
  8485. * Defines the target the camera should look at.
  8486. * @param target Defines the new target as a Vector or a mesh
  8487. */
  8488. setTarget(target: Vector3): void;
  8489. /**
  8490. * Return the current target position of the camera. This value is expressed in local space.
  8491. * @returns the target position
  8492. */
  8493. getTarget(): Vector3;
  8494. /** @hidden */
  8495. _decideIfNeedsToMove(): boolean;
  8496. /** @hidden */
  8497. _updatePosition(): void;
  8498. /** @hidden */
  8499. _checkInputs(): void;
  8500. protected _updateCameraRotationMatrix(): void;
  8501. /**
  8502. * 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)
  8503. * @returns the current camera
  8504. */
  8505. private _rotateUpVectorWithCameraRotationMatrix;
  8506. private _cachedRotationZ;
  8507. private _cachedQuaternionRotationZ;
  8508. /** @hidden */
  8509. _getViewMatrix(): Matrix;
  8510. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8511. /**
  8512. * @hidden
  8513. */
  8514. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8515. /**
  8516. * @hidden
  8517. */
  8518. _updateRigCameras(): void;
  8519. private _getRigCamPositionAndTarget;
  8520. /**
  8521. * Gets the current object class name.
  8522. * @return the class name
  8523. */
  8524. getClassName(): string;
  8525. }
  8526. }
  8527. declare module BABYLON {
  8528. /**
  8529. * Gather the list of keyboard event types as constants.
  8530. */
  8531. export class KeyboardEventTypes {
  8532. /**
  8533. * The keydown event is fired when a key becomes active (pressed).
  8534. */
  8535. static readonly KEYDOWN: number;
  8536. /**
  8537. * The keyup event is fired when a key has been released.
  8538. */
  8539. static readonly KEYUP: number;
  8540. }
  8541. /**
  8542. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8543. */
  8544. export class KeyboardInfo {
  8545. /**
  8546. * Defines the type of event (KeyboardEventTypes)
  8547. */
  8548. type: number;
  8549. /**
  8550. * Defines the related dom event
  8551. */
  8552. event: KeyboardEvent;
  8553. /**
  8554. * Instantiates a new keyboard info.
  8555. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8556. * @param type Defines the type of event (KeyboardEventTypes)
  8557. * @param event Defines the related dom event
  8558. */
  8559. constructor(
  8560. /**
  8561. * Defines the type of event (KeyboardEventTypes)
  8562. */
  8563. type: number,
  8564. /**
  8565. * Defines the related dom event
  8566. */
  8567. event: KeyboardEvent);
  8568. }
  8569. /**
  8570. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8571. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8572. */
  8573. export class KeyboardInfoPre extends KeyboardInfo {
  8574. /**
  8575. * Defines the type of event (KeyboardEventTypes)
  8576. */
  8577. type: number;
  8578. /**
  8579. * Defines the related dom event
  8580. */
  8581. event: KeyboardEvent;
  8582. /**
  8583. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8584. */
  8585. skipOnPointerObservable: boolean;
  8586. /**
  8587. * Instantiates a new keyboard pre info.
  8588. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8589. * @param type Defines the type of event (KeyboardEventTypes)
  8590. * @param event Defines the related dom event
  8591. */
  8592. constructor(
  8593. /**
  8594. * Defines the type of event (KeyboardEventTypes)
  8595. */
  8596. type: number,
  8597. /**
  8598. * Defines the related dom event
  8599. */
  8600. event: KeyboardEvent);
  8601. }
  8602. }
  8603. declare module BABYLON {
  8604. /**
  8605. * Manage the keyboard inputs to control the movement of a free camera.
  8606. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8607. */
  8608. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8609. /**
  8610. * Defines the camera the input is attached to.
  8611. */
  8612. camera: FreeCamera;
  8613. /**
  8614. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8615. */
  8616. keysUp: number[];
  8617. /**
  8618. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8619. */
  8620. keysDown: number[];
  8621. /**
  8622. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8623. */
  8624. keysLeft: number[];
  8625. /**
  8626. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8627. */
  8628. keysRight: number[];
  8629. private _keys;
  8630. private _onCanvasBlurObserver;
  8631. private _onKeyboardObserver;
  8632. private _engine;
  8633. private _scene;
  8634. /**
  8635. * Attach the input controls to a specific dom element to get the input from.
  8636. * @param element Defines the element the controls should be listened from
  8637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8638. */
  8639. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8640. /**
  8641. * Detach the current controls from the specified dom element.
  8642. * @param element Defines the element to stop listening the inputs from
  8643. */
  8644. detachControl(element: Nullable<HTMLElement>): void;
  8645. /**
  8646. * Update the current camera state depending on the inputs that have been used this frame.
  8647. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8648. */
  8649. checkInputs(): void;
  8650. /**
  8651. * Gets the class name of the current intput.
  8652. * @returns the class name
  8653. */
  8654. getClassName(): string;
  8655. /** @hidden */
  8656. _onLostFocus(): void;
  8657. /**
  8658. * Get the friendly name associated with the input class.
  8659. * @returns the input friendly name
  8660. */
  8661. getSimpleName(): string;
  8662. }
  8663. }
  8664. declare module BABYLON {
  8665. /**
  8666. * Interface describing all the common properties and methods a shadow light needs to implement.
  8667. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8668. * as well as binding the different shadow properties to the effects.
  8669. */
  8670. export interface IShadowLight extends Light {
  8671. /**
  8672. * The light id in the scene (used in scene.findLighById for instance)
  8673. */
  8674. id: string;
  8675. /**
  8676. * The position the shdow will be casted from.
  8677. */
  8678. position: Vector3;
  8679. /**
  8680. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8681. */
  8682. direction: Vector3;
  8683. /**
  8684. * The transformed position. Position of the light in world space taking parenting in account.
  8685. */
  8686. transformedPosition: Vector3;
  8687. /**
  8688. * The transformed direction. Direction of the light in world space taking parenting in account.
  8689. */
  8690. transformedDirection: Vector3;
  8691. /**
  8692. * The friendly name of the light in the scene.
  8693. */
  8694. name: string;
  8695. /**
  8696. * Defines the shadow projection clipping minimum z value.
  8697. */
  8698. shadowMinZ: number;
  8699. /**
  8700. * Defines the shadow projection clipping maximum z value.
  8701. */
  8702. shadowMaxZ: number;
  8703. /**
  8704. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8705. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8706. */
  8707. computeTransformedInformation(): boolean;
  8708. /**
  8709. * Gets the scene the light belongs to.
  8710. * @returns The scene
  8711. */
  8712. getScene(): Scene;
  8713. /**
  8714. * Callback defining a custom Projection Matrix Builder.
  8715. * This can be used to override the default projection matrix computation.
  8716. */
  8717. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8718. /**
  8719. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8720. * @param matrix The materix to updated with the projection information
  8721. * @param viewMatrix The transform matrix of the light
  8722. * @param renderList The list of mesh to render in the map
  8723. * @returns The current light
  8724. */
  8725. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8726. /**
  8727. * Gets the current depth scale used in ESM.
  8728. * @returns The scale
  8729. */
  8730. getDepthScale(): number;
  8731. /**
  8732. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8733. * @returns true if a cube texture needs to be use
  8734. */
  8735. needCube(): boolean;
  8736. /**
  8737. * Detects if the projection matrix requires to be recomputed this frame.
  8738. * @returns true if it requires to be recomputed otherwise, false.
  8739. */
  8740. needProjectionMatrixCompute(): boolean;
  8741. /**
  8742. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8743. */
  8744. forceProjectionMatrixCompute(): void;
  8745. /**
  8746. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8747. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8748. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8749. */
  8750. getShadowDirection(faceIndex?: number): Vector3;
  8751. /**
  8752. * Gets the minZ used for shadow according to both the scene and the light.
  8753. * @param activeCamera The camera we are returning the min for
  8754. * @returns the depth min z
  8755. */
  8756. getDepthMinZ(activeCamera: Camera): number;
  8757. /**
  8758. * Gets the maxZ used for shadow according to both the scene and the light.
  8759. * @param activeCamera The camera we are returning the max for
  8760. * @returns the depth max z
  8761. */
  8762. getDepthMaxZ(activeCamera: Camera): number;
  8763. }
  8764. /**
  8765. * Base implementation IShadowLight
  8766. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8767. */
  8768. export abstract class ShadowLight extends Light implements IShadowLight {
  8769. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8770. protected _position: Vector3;
  8771. protected _setPosition(value: Vector3): void;
  8772. /**
  8773. * Sets the position the shadow will be casted from. Also use as the light position for both
  8774. * point and spot lights.
  8775. */
  8776. /**
  8777. * Sets the position the shadow will be casted from. Also use as the light position for both
  8778. * point and spot lights.
  8779. */
  8780. position: Vector3;
  8781. protected _direction: Vector3;
  8782. protected _setDirection(value: Vector3): void;
  8783. /**
  8784. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8785. * Also use as the light direction on spot and directional lights.
  8786. */
  8787. /**
  8788. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8789. * Also use as the light direction on spot and directional lights.
  8790. */
  8791. direction: Vector3;
  8792. private _shadowMinZ;
  8793. /**
  8794. * Gets the shadow projection clipping minimum z value.
  8795. */
  8796. /**
  8797. * Sets the shadow projection clipping minimum z value.
  8798. */
  8799. shadowMinZ: number;
  8800. private _shadowMaxZ;
  8801. /**
  8802. * Sets the shadow projection clipping maximum z value.
  8803. */
  8804. /**
  8805. * Gets the shadow projection clipping maximum z value.
  8806. */
  8807. shadowMaxZ: number;
  8808. /**
  8809. * Callback defining a custom Projection Matrix Builder.
  8810. * This can be used to override the default projection matrix computation.
  8811. */
  8812. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8813. /**
  8814. * The transformed position. Position of the light in world space taking parenting in account.
  8815. */
  8816. transformedPosition: Vector3;
  8817. /**
  8818. * The transformed direction. Direction of the light in world space taking parenting in account.
  8819. */
  8820. transformedDirection: Vector3;
  8821. private _needProjectionMatrixCompute;
  8822. /**
  8823. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8824. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8825. */
  8826. computeTransformedInformation(): boolean;
  8827. /**
  8828. * Return the depth scale used for the shadow map.
  8829. * @returns the depth scale.
  8830. */
  8831. getDepthScale(): number;
  8832. /**
  8833. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8834. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8835. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8836. */
  8837. getShadowDirection(faceIndex?: number): Vector3;
  8838. /**
  8839. * Returns the ShadowLight absolute position in the World.
  8840. * @returns the position vector in world space
  8841. */
  8842. getAbsolutePosition(): Vector3;
  8843. /**
  8844. * Sets the ShadowLight direction toward the passed target.
  8845. * @param target The point to target in local space
  8846. * @returns the updated ShadowLight direction
  8847. */
  8848. setDirectionToTarget(target: Vector3): Vector3;
  8849. /**
  8850. * Returns the light rotation in euler definition.
  8851. * @returns the x y z rotation in local space.
  8852. */
  8853. getRotation(): Vector3;
  8854. /**
  8855. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8856. * @returns true if a cube texture needs to be use
  8857. */
  8858. needCube(): boolean;
  8859. /**
  8860. * Detects if the projection matrix requires to be recomputed this frame.
  8861. * @returns true if it requires to be recomputed otherwise, false.
  8862. */
  8863. needProjectionMatrixCompute(): boolean;
  8864. /**
  8865. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8866. */
  8867. forceProjectionMatrixCompute(): void;
  8868. /** @hidden */
  8869. _initCache(): void;
  8870. /** @hidden */
  8871. _isSynchronized(): boolean;
  8872. /**
  8873. * Computes the world matrix of the node
  8874. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8875. * @returns the world matrix
  8876. */
  8877. computeWorldMatrix(force?: boolean): Matrix;
  8878. /**
  8879. * Gets the minZ used for shadow according to both the scene and the light.
  8880. * @param activeCamera The camera we are returning the min for
  8881. * @returns the depth min z
  8882. */
  8883. getDepthMinZ(activeCamera: Camera): number;
  8884. /**
  8885. * Gets the maxZ used for shadow according to both the scene and the light.
  8886. * @param activeCamera The camera we are returning the max for
  8887. * @returns the depth max z
  8888. */
  8889. getDepthMaxZ(activeCamera: Camera): number;
  8890. /**
  8891. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8892. * @param matrix The materix to updated with the projection information
  8893. * @param viewMatrix The transform matrix of the light
  8894. * @param renderList The list of mesh to render in the map
  8895. * @returns The current light
  8896. */
  8897. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8898. }
  8899. }
  8900. declare module BABYLON {
  8901. /**
  8902. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8903. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8904. */
  8905. export class EffectFallbacks implements IEffectFallbacks {
  8906. private _defines;
  8907. private _currentRank;
  8908. private _maxRank;
  8909. private _mesh;
  8910. /**
  8911. * Removes the fallback from the bound mesh.
  8912. */
  8913. unBindMesh(): void;
  8914. /**
  8915. * Adds a fallback on the specified property.
  8916. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8917. * @param define The name of the define in the shader
  8918. */
  8919. addFallback(rank: number, define: string): void;
  8920. /**
  8921. * Sets the mesh to use CPU skinning when needing to fallback.
  8922. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8923. * @param mesh The mesh to use the fallbacks.
  8924. */
  8925. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8926. /**
  8927. * Checks to see if more fallbacks are still availible.
  8928. */
  8929. readonly hasMoreFallbacks: boolean;
  8930. /**
  8931. * Removes the defines that should be removed when falling back.
  8932. * @param currentDefines defines the current define statements for the shader.
  8933. * @param effect defines the current effect we try to compile
  8934. * @returns The resulting defines with defines of the current rank removed.
  8935. */
  8936. reduce(currentDefines: string, effect: Effect): string;
  8937. }
  8938. }
  8939. declare module BABYLON {
  8940. /**
  8941. * "Static Class" containing the most commonly used helper while dealing with material for
  8942. * rendering purpose.
  8943. *
  8944. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8945. *
  8946. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8947. */
  8948. export class MaterialHelper {
  8949. /**
  8950. * Bind the current view position to an effect.
  8951. * @param effect The effect to be bound
  8952. * @param scene The scene the eyes position is used from
  8953. */
  8954. static BindEyePosition(effect: Effect, scene: Scene): void;
  8955. /**
  8956. * Helps preparing the defines values about the UVs in used in the effect.
  8957. * UVs are shared as much as we can accross channels in the shaders.
  8958. * @param texture The texture we are preparing the UVs for
  8959. * @param defines The defines to update
  8960. * @param key The channel key "diffuse", "specular"... used in the shader
  8961. */
  8962. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8963. /**
  8964. * Binds a texture matrix value to its corrsponding uniform
  8965. * @param texture The texture to bind the matrix for
  8966. * @param uniformBuffer The uniform buffer receivin the data
  8967. * @param key The channel key "diffuse", "specular"... used in the shader
  8968. */
  8969. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8970. /**
  8971. * Gets the current status of the fog (should it be enabled?)
  8972. * @param mesh defines the mesh to evaluate for fog support
  8973. * @param scene defines the hosting scene
  8974. * @returns true if fog must be enabled
  8975. */
  8976. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8977. /**
  8978. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8979. * @param mesh defines the current mesh
  8980. * @param scene defines the current scene
  8981. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8982. * @param pointsCloud defines if point cloud rendering has to be turned on
  8983. * @param fogEnabled defines if fog has to be turned on
  8984. * @param alphaTest defines if alpha testing has to be turned on
  8985. * @param defines defines the current list of defines
  8986. */
  8987. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8988. /**
  8989. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8990. * @param scene defines the current scene
  8991. * @param engine defines the current engine
  8992. * @param defines specifies the list of active defines
  8993. * @param useInstances defines if instances have to be turned on
  8994. * @param useClipPlane defines if clip plane have to be turned on
  8995. */
  8996. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8997. /**
  8998. * Prepares the defines for bones
  8999. * @param mesh The mesh containing the geometry data we will draw
  9000. * @param defines The defines to update
  9001. */
  9002. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9003. /**
  9004. * Prepares the defines for morph targets
  9005. * @param mesh The mesh containing the geometry data we will draw
  9006. * @param defines The defines to update
  9007. */
  9008. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9009. /**
  9010. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9011. * @param mesh The mesh containing the geometry data we will draw
  9012. * @param defines The defines to update
  9013. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9014. * @param useBones Precise whether bones should be used or not (override mesh info)
  9015. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9016. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9017. * @returns false if defines are considered not dirty and have not been checked
  9018. */
  9019. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9020. /**
  9021. * Prepares the defines related to multiview
  9022. * @param scene The scene we are intending to draw
  9023. * @param defines The defines to update
  9024. */
  9025. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9026. /**
  9027. * Prepares the defines related to the light information passed in parameter
  9028. * @param scene The scene we are intending to draw
  9029. * @param mesh The mesh the effect is compiling for
  9030. * @param light The light the effect is compiling for
  9031. * @param lightIndex The index of the light
  9032. * @param defines The defines to update
  9033. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9034. * @param state Defines the current state regarding what is needed (normals, etc...)
  9035. */
  9036. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9037. needNormals: boolean;
  9038. needRebuild: boolean;
  9039. shadowEnabled: boolean;
  9040. specularEnabled: boolean;
  9041. lightmapMode: boolean;
  9042. }): void;
  9043. /**
  9044. * Prepares the defines related to the light information passed in parameter
  9045. * @param scene The scene we are intending to draw
  9046. * @param mesh The mesh the effect is compiling for
  9047. * @param defines The defines to update
  9048. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9049. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9050. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9051. * @returns true if normals will be required for the rest of the effect
  9052. */
  9053. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9054. /**
  9055. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9056. * @param lightIndex defines the light index
  9057. * @param uniformsList The uniform list
  9058. * @param samplersList The sampler list
  9059. * @param projectedLightTexture defines if projected texture must be used
  9060. * @param uniformBuffersList defines an optional list of uniform buffers
  9061. */
  9062. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9063. /**
  9064. * Prepares the uniforms and samplers list to be used in the effect
  9065. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9066. * @param samplersList The sampler list
  9067. * @param defines The defines helping in the list generation
  9068. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9069. */
  9070. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9071. /**
  9072. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9073. * @param defines The defines to update while falling back
  9074. * @param fallbacks The authorized effect fallbacks
  9075. * @param maxSimultaneousLights The maximum number of lights allowed
  9076. * @param rank the current rank of the Effect
  9077. * @returns The newly affected rank
  9078. */
  9079. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9080. private static _TmpMorphInfluencers;
  9081. /**
  9082. * Prepares the list of attributes required for morph targets according to the effect defines.
  9083. * @param attribs The current list of supported attribs
  9084. * @param mesh The mesh to prepare the morph targets attributes for
  9085. * @param influencers The number of influencers
  9086. */
  9087. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9088. /**
  9089. * Prepares the list of attributes required for morph targets according to the effect defines.
  9090. * @param attribs The current list of supported attribs
  9091. * @param mesh The mesh to prepare the morph targets attributes for
  9092. * @param defines The current Defines of the effect
  9093. */
  9094. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9095. /**
  9096. * Prepares the list of attributes required for bones according to the effect defines.
  9097. * @param attribs The current list of supported attribs
  9098. * @param mesh The mesh to prepare the bones attributes for
  9099. * @param defines The current Defines of the effect
  9100. * @param fallbacks The current efffect fallback strategy
  9101. */
  9102. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9103. /**
  9104. * Check and prepare the list of attributes required for instances according to the effect defines.
  9105. * @param attribs The current list of supported attribs
  9106. * @param defines The current MaterialDefines of the effect
  9107. */
  9108. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9109. /**
  9110. * Add the list of attributes required for instances to the attribs array.
  9111. * @param attribs The current list of supported attribs
  9112. */
  9113. static PushAttributesForInstances(attribs: string[]): void;
  9114. /**
  9115. * Binds the light shadow information to the effect for the given mesh.
  9116. * @param light The light containing the generator
  9117. * @param scene The scene the lights belongs to
  9118. * @param mesh The mesh we are binding the information to render
  9119. * @param lightIndex The light index in the effect used to render the mesh
  9120. * @param effect The effect we are binding the data to
  9121. */
  9122. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9123. /**
  9124. * Binds the light information to the effect.
  9125. * @param light The light containing the generator
  9126. * @param effect The effect we are binding the data to
  9127. * @param lightIndex The light index in the effect used to render
  9128. */
  9129. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9130. /**
  9131. * Binds the lights information from the scene to the effect for the given mesh.
  9132. * @param light Light to bind
  9133. * @param lightIndex Light index
  9134. * @param scene The scene where the light belongs to
  9135. * @param mesh The mesh we are binding the information to render
  9136. * @param effect The effect we are binding the data to
  9137. * @param useSpecular Defines if specular is supported
  9138. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9139. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9140. */
  9141. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9142. /**
  9143. * Binds the lights information from the scene to the effect for the given mesh.
  9144. * @param scene The scene the lights belongs to
  9145. * @param mesh The mesh we are binding the information to render
  9146. * @param effect The effect we are binding the data to
  9147. * @param defines The generated defines for the effect
  9148. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9149. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9150. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9151. */
  9152. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9153. private static _tempFogColor;
  9154. /**
  9155. * Binds the fog information from the scene to the effect for the given mesh.
  9156. * @param scene The scene the lights belongs to
  9157. * @param mesh The mesh we are binding the information to render
  9158. * @param effect The effect we are binding the data to
  9159. * @param linearSpace Defines if the fog effect is applied in linear space
  9160. */
  9161. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9162. /**
  9163. * Binds the bones information from the mesh to the effect.
  9164. * @param mesh The mesh we are binding the information to render
  9165. * @param effect The effect we are binding the data to
  9166. */
  9167. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9168. /**
  9169. * Binds the morph targets information from the mesh to the effect.
  9170. * @param abstractMesh The mesh we are binding the information to render
  9171. * @param effect The effect we are binding the data to
  9172. */
  9173. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9174. /**
  9175. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9176. * @param defines The generated defines used in the effect
  9177. * @param effect The effect we are binding the data to
  9178. * @param scene The scene we are willing to render with logarithmic scale for
  9179. */
  9180. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9181. /**
  9182. * Binds the clip plane information from the scene to the effect.
  9183. * @param scene The scene the clip plane information are extracted from
  9184. * @param effect The effect we are binding the data to
  9185. */
  9186. static BindClipPlane(effect: Effect, scene: Scene): void;
  9187. }
  9188. }
  9189. declare module BABYLON {
  9190. /** @hidden */
  9191. export var packingFunctions: {
  9192. name: string;
  9193. shader: string;
  9194. };
  9195. }
  9196. declare module BABYLON {
  9197. /** @hidden */
  9198. export var shadowMapPixelShader: {
  9199. name: string;
  9200. shader: string;
  9201. };
  9202. }
  9203. declare module BABYLON {
  9204. /** @hidden */
  9205. export var bonesDeclaration: {
  9206. name: string;
  9207. shader: string;
  9208. };
  9209. }
  9210. declare module BABYLON {
  9211. /** @hidden */
  9212. export var morphTargetsVertexGlobalDeclaration: {
  9213. name: string;
  9214. shader: string;
  9215. };
  9216. }
  9217. declare module BABYLON {
  9218. /** @hidden */
  9219. export var morphTargetsVertexDeclaration: {
  9220. name: string;
  9221. shader: string;
  9222. };
  9223. }
  9224. declare module BABYLON {
  9225. /** @hidden */
  9226. export var instancesDeclaration: {
  9227. name: string;
  9228. shader: string;
  9229. };
  9230. }
  9231. declare module BABYLON {
  9232. /** @hidden */
  9233. export var helperFunctions: {
  9234. name: string;
  9235. shader: string;
  9236. };
  9237. }
  9238. declare module BABYLON {
  9239. /** @hidden */
  9240. export var morphTargetsVertex: {
  9241. name: string;
  9242. shader: string;
  9243. };
  9244. }
  9245. declare module BABYLON {
  9246. /** @hidden */
  9247. export var instancesVertex: {
  9248. name: string;
  9249. shader: string;
  9250. };
  9251. }
  9252. declare module BABYLON {
  9253. /** @hidden */
  9254. export var bonesVertex: {
  9255. name: string;
  9256. shader: string;
  9257. };
  9258. }
  9259. declare module BABYLON {
  9260. /** @hidden */
  9261. export var shadowMapVertexShader: {
  9262. name: string;
  9263. shader: string;
  9264. };
  9265. }
  9266. declare module BABYLON {
  9267. /** @hidden */
  9268. export var depthBoxBlurPixelShader: {
  9269. name: string;
  9270. shader: string;
  9271. };
  9272. }
  9273. declare module BABYLON {
  9274. /**
  9275. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9276. */
  9277. export interface ICustomShaderOptions {
  9278. /**
  9279. * Gets or sets the custom shader name to use
  9280. */
  9281. shaderName: string;
  9282. /**
  9283. * The list of attribute names used in the shader
  9284. */
  9285. attributes?: string[];
  9286. /**
  9287. * The list of unifrom names used in the shader
  9288. */
  9289. uniforms?: string[];
  9290. /**
  9291. * The list of sampler names used in the shader
  9292. */
  9293. samplers?: string[];
  9294. /**
  9295. * The list of defines used in the shader
  9296. */
  9297. defines?: string[];
  9298. }
  9299. /**
  9300. * Interface to implement to create a shadow generator compatible with BJS.
  9301. */
  9302. export interface IShadowGenerator {
  9303. /**
  9304. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9305. * @returns The render target texture if present otherwise, null
  9306. */
  9307. getShadowMap(): Nullable<RenderTargetTexture>;
  9308. /**
  9309. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9310. * @returns The render target texture if the shadow map is present otherwise, null
  9311. */
  9312. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9313. /**
  9314. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9315. * @param subMesh The submesh we want to render in the shadow map
  9316. * @param useInstances Defines wether will draw in the map using instances
  9317. * @returns true if ready otherwise, false
  9318. */
  9319. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9320. /**
  9321. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9322. * @param defines Defines of the material we want to update
  9323. * @param lightIndex Index of the light in the enabled light list of the material
  9324. */
  9325. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9326. /**
  9327. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9328. * defined in the generator but impacting the effect).
  9329. * It implies the unifroms available on the materials are the standard BJS ones.
  9330. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9331. * @param effect The effect we are binfing the information for
  9332. */
  9333. bindShadowLight(lightIndex: string, effect: Effect): void;
  9334. /**
  9335. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9336. * (eq to shadow prjection matrix * light transform matrix)
  9337. * @returns The transform matrix used to create the shadow map
  9338. */
  9339. getTransformMatrix(): Matrix;
  9340. /**
  9341. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9342. * Cube and 2D textures for instance.
  9343. */
  9344. recreateShadowMap(): void;
  9345. /**
  9346. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9347. * @param onCompiled Callback triggered at the and of the effects compilation
  9348. * @param options Sets of optional options forcing the compilation with different modes
  9349. */
  9350. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9351. useInstances: boolean;
  9352. }>): void;
  9353. /**
  9354. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9355. * @param options Sets of optional options forcing the compilation with different modes
  9356. * @returns A promise that resolves when the compilation completes
  9357. */
  9358. forceCompilationAsync(options?: Partial<{
  9359. useInstances: boolean;
  9360. }>): Promise<void>;
  9361. /**
  9362. * Serializes the shadow generator setup to a json object.
  9363. * @returns The serialized JSON object
  9364. */
  9365. serialize(): any;
  9366. /**
  9367. * Disposes the Shadow map and related Textures and effects.
  9368. */
  9369. dispose(): void;
  9370. }
  9371. /**
  9372. * Default implementation IShadowGenerator.
  9373. * This is the main object responsible of generating shadows in the framework.
  9374. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9375. */
  9376. export class ShadowGenerator implements IShadowGenerator {
  9377. /**
  9378. * Shadow generator mode None: no filtering applied.
  9379. */
  9380. static readonly FILTER_NONE: number;
  9381. /**
  9382. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9383. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9384. */
  9385. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9386. /**
  9387. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9388. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9389. */
  9390. static readonly FILTER_POISSONSAMPLING: number;
  9391. /**
  9392. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9393. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9394. */
  9395. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9396. /**
  9397. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9398. * edge artifacts on steep falloff.
  9399. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9400. */
  9401. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9402. /**
  9403. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9404. * edge artifacts on steep falloff.
  9405. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9406. */
  9407. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9408. /**
  9409. * Shadow generator mode PCF: Percentage Closer Filtering
  9410. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9411. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9412. */
  9413. static readonly FILTER_PCF: number;
  9414. /**
  9415. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9416. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9417. * Contact Hardening
  9418. */
  9419. static readonly FILTER_PCSS: number;
  9420. /**
  9421. * Reserved for PCF and PCSS
  9422. * Highest Quality.
  9423. *
  9424. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9425. *
  9426. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9427. */
  9428. static readonly QUALITY_HIGH: number;
  9429. /**
  9430. * Reserved for PCF and PCSS
  9431. * Good tradeoff for quality/perf cross devices
  9432. *
  9433. * Execute PCF on a 3*3 kernel.
  9434. *
  9435. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9436. */
  9437. static readonly QUALITY_MEDIUM: number;
  9438. /**
  9439. * Reserved for PCF and PCSS
  9440. * The lowest quality but the fastest.
  9441. *
  9442. * Execute PCF on a 1*1 kernel.
  9443. *
  9444. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9445. */
  9446. static readonly QUALITY_LOW: number;
  9447. /** Gets or sets the custom shader name to use */
  9448. customShaderOptions: ICustomShaderOptions;
  9449. /**
  9450. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9451. */
  9452. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9453. /**
  9454. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9455. */
  9456. onAfterShadowMapRenderObservable: Observable<Effect>;
  9457. /**
  9458. * Observable triggered before a mesh is rendered in the shadow map.
  9459. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9460. */
  9461. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9462. /**
  9463. * Observable triggered after a mesh is rendered in the shadow map.
  9464. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9465. */
  9466. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9467. private _bias;
  9468. /**
  9469. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9470. */
  9471. /**
  9472. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9473. */
  9474. bias: number;
  9475. private _normalBias;
  9476. /**
  9477. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9478. */
  9479. /**
  9480. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9481. */
  9482. normalBias: number;
  9483. private _blurBoxOffset;
  9484. /**
  9485. * Gets the blur box offset: offset applied during the blur pass.
  9486. * Only useful if useKernelBlur = false
  9487. */
  9488. /**
  9489. * Sets the blur box offset: offset applied during the blur pass.
  9490. * Only useful if useKernelBlur = false
  9491. */
  9492. blurBoxOffset: number;
  9493. private _blurScale;
  9494. /**
  9495. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9496. * 2 means half of the size.
  9497. */
  9498. /**
  9499. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9500. * 2 means half of the size.
  9501. */
  9502. blurScale: number;
  9503. private _blurKernel;
  9504. /**
  9505. * Gets the blur kernel: kernel size of the blur pass.
  9506. * Only useful if useKernelBlur = true
  9507. */
  9508. /**
  9509. * Sets the blur kernel: kernel size of the blur pass.
  9510. * Only useful if useKernelBlur = true
  9511. */
  9512. blurKernel: number;
  9513. private _useKernelBlur;
  9514. /**
  9515. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9516. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9517. */
  9518. /**
  9519. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9520. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9521. */
  9522. useKernelBlur: boolean;
  9523. private _depthScale;
  9524. /**
  9525. * Gets the depth scale used in ESM mode.
  9526. */
  9527. /**
  9528. * Sets the depth scale used in ESM mode.
  9529. * This can override the scale stored on the light.
  9530. */
  9531. depthScale: number;
  9532. private _filter;
  9533. /**
  9534. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9535. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9536. */
  9537. /**
  9538. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9539. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9540. */
  9541. filter: number;
  9542. /**
  9543. * Gets if the current filter is set to Poisson Sampling.
  9544. */
  9545. /**
  9546. * Sets the current filter to Poisson Sampling.
  9547. */
  9548. usePoissonSampling: boolean;
  9549. /**
  9550. * Gets if the current filter is set to ESM.
  9551. */
  9552. /**
  9553. * Sets the current filter is to ESM.
  9554. */
  9555. useExponentialShadowMap: boolean;
  9556. /**
  9557. * Gets if the current filter is set to filtered ESM.
  9558. */
  9559. /**
  9560. * Gets if the current filter is set to filtered ESM.
  9561. */
  9562. useBlurExponentialShadowMap: boolean;
  9563. /**
  9564. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9565. * exponential to prevent steep falloff artifacts).
  9566. */
  9567. /**
  9568. * Sets the current filter to "close ESM" (using the inverse of the
  9569. * exponential to prevent steep falloff artifacts).
  9570. */
  9571. useCloseExponentialShadowMap: boolean;
  9572. /**
  9573. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9574. * exponential to prevent steep falloff artifacts).
  9575. */
  9576. /**
  9577. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9578. * exponential to prevent steep falloff artifacts).
  9579. */
  9580. useBlurCloseExponentialShadowMap: boolean;
  9581. /**
  9582. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9583. */
  9584. /**
  9585. * Sets the current filter to "PCF" (percentage closer filtering).
  9586. */
  9587. usePercentageCloserFiltering: boolean;
  9588. private _filteringQuality;
  9589. /**
  9590. * Gets the PCF or PCSS Quality.
  9591. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9592. */
  9593. /**
  9594. * Sets the PCF or PCSS Quality.
  9595. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9596. */
  9597. filteringQuality: number;
  9598. /**
  9599. * Gets if the current filter is set to "PCSS" (contact hardening).
  9600. */
  9601. /**
  9602. * Sets the current filter to "PCSS" (contact hardening).
  9603. */
  9604. useContactHardeningShadow: boolean;
  9605. private _contactHardeningLightSizeUVRatio;
  9606. /**
  9607. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9608. * Using a ratio helps keeping shape stability independently of the map size.
  9609. *
  9610. * It does not account for the light projection as it was having too much
  9611. * instability during the light setup or during light position changes.
  9612. *
  9613. * Only valid if useContactHardeningShadow is true.
  9614. */
  9615. /**
  9616. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9617. * Using a ratio helps keeping shape stability independently of the map size.
  9618. *
  9619. * It does not account for the light projection as it was having too much
  9620. * instability during the light setup or during light position changes.
  9621. *
  9622. * Only valid if useContactHardeningShadow is true.
  9623. */
  9624. contactHardeningLightSizeUVRatio: number;
  9625. private _darkness;
  9626. /** Gets or sets the actual darkness of a shadow */
  9627. darkness: number;
  9628. /**
  9629. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9630. * 0 means strongest and 1 would means no shadow.
  9631. * @returns the darkness.
  9632. */
  9633. getDarkness(): number;
  9634. /**
  9635. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9636. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9637. * @returns the shadow generator allowing fluent coding.
  9638. */
  9639. setDarkness(darkness: number): ShadowGenerator;
  9640. private _transparencyShadow;
  9641. /** Gets or sets the ability to have transparent shadow */
  9642. transparencyShadow: boolean;
  9643. /**
  9644. * Sets the ability to have transparent shadow (boolean).
  9645. * @param transparent True if transparent else False
  9646. * @returns the shadow generator allowing fluent coding
  9647. */
  9648. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9649. private _shadowMap;
  9650. private _shadowMap2;
  9651. /**
  9652. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9653. * @returns The render target texture if present otherwise, null
  9654. */
  9655. getShadowMap(): Nullable<RenderTargetTexture>;
  9656. /**
  9657. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9658. * @returns The render target texture if the shadow map is present otherwise, null
  9659. */
  9660. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9661. /**
  9662. * Gets the class name of that object
  9663. * @returns "ShadowGenerator"
  9664. */
  9665. getClassName(): string;
  9666. /**
  9667. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9668. * @param mesh Mesh to add
  9669. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9670. * @returns the Shadow Generator itself
  9671. */
  9672. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9673. /**
  9674. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9675. * @param mesh Mesh to remove
  9676. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9677. * @returns the Shadow Generator itself
  9678. */
  9679. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9680. /**
  9681. * Controls the extent to which the shadows fade out at the edge of the frustum
  9682. * Used only by directionals and spots
  9683. */
  9684. frustumEdgeFalloff: number;
  9685. private _light;
  9686. /**
  9687. * Returns the associated light object.
  9688. * @returns the light generating the shadow
  9689. */
  9690. getLight(): IShadowLight;
  9691. /**
  9692. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9693. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9694. * It might on the other hand introduce peter panning.
  9695. */
  9696. forceBackFacesOnly: boolean;
  9697. private _scene;
  9698. private _lightDirection;
  9699. private _effect;
  9700. private _viewMatrix;
  9701. private _projectionMatrix;
  9702. private _transformMatrix;
  9703. private _cachedPosition;
  9704. private _cachedDirection;
  9705. private _cachedDefines;
  9706. private _currentRenderID;
  9707. private _boxBlurPostprocess;
  9708. private _kernelBlurXPostprocess;
  9709. private _kernelBlurYPostprocess;
  9710. private _blurPostProcesses;
  9711. private _mapSize;
  9712. private _currentFaceIndex;
  9713. private _currentFaceIndexCache;
  9714. private _textureType;
  9715. private _defaultTextureMatrix;
  9716. private _storedUniqueId;
  9717. /** @hidden */
  9718. static _SceneComponentInitialization: (scene: Scene) => void;
  9719. /**
  9720. * Creates a ShadowGenerator object.
  9721. * A ShadowGenerator is the required tool to use the shadows.
  9722. * Each light casting shadows needs to use its own ShadowGenerator.
  9723. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9724. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9725. * @param light The light object generating the shadows.
  9726. * @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.
  9727. */
  9728. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9729. private _initializeGenerator;
  9730. private _initializeShadowMap;
  9731. private _initializeBlurRTTAndPostProcesses;
  9732. private _renderForShadowMap;
  9733. private _renderSubMeshForShadowMap;
  9734. private _applyFilterValues;
  9735. /**
  9736. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9737. * @param onCompiled Callback triggered at the and of the effects compilation
  9738. * @param options Sets of optional options forcing the compilation with different modes
  9739. */
  9740. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9741. useInstances: boolean;
  9742. }>): void;
  9743. /**
  9744. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9745. * @param options Sets of optional options forcing the compilation with different modes
  9746. * @returns A promise that resolves when the compilation completes
  9747. */
  9748. forceCompilationAsync(options?: Partial<{
  9749. useInstances: boolean;
  9750. }>): Promise<void>;
  9751. /**
  9752. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9753. * @param subMesh The submesh we want to render in the shadow map
  9754. * @param useInstances Defines wether will draw in the map using instances
  9755. * @returns true if ready otherwise, false
  9756. */
  9757. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9758. /**
  9759. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9760. * @param defines Defines of the material we want to update
  9761. * @param lightIndex Index of the light in the enabled light list of the material
  9762. */
  9763. prepareDefines(defines: any, lightIndex: number): void;
  9764. /**
  9765. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9766. * defined in the generator but impacting the effect).
  9767. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9768. * @param effect The effect we are binfing the information for
  9769. */
  9770. bindShadowLight(lightIndex: string, effect: Effect): void;
  9771. /**
  9772. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9773. * (eq to shadow prjection matrix * light transform matrix)
  9774. * @returns The transform matrix used to create the shadow map
  9775. */
  9776. getTransformMatrix(): Matrix;
  9777. /**
  9778. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9779. * Cube and 2D textures for instance.
  9780. */
  9781. recreateShadowMap(): void;
  9782. private _disposeBlurPostProcesses;
  9783. private _disposeRTTandPostProcesses;
  9784. /**
  9785. * Disposes the ShadowGenerator.
  9786. * Returns nothing.
  9787. */
  9788. dispose(): void;
  9789. /**
  9790. * Serializes the shadow generator setup to a json object.
  9791. * @returns The serialized JSON object
  9792. */
  9793. serialize(): any;
  9794. /**
  9795. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9796. * @param parsedShadowGenerator The JSON object to parse
  9797. * @param scene The scene to create the shadow map for
  9798. * @returns The parsed shadow generator
  9799. */
  9800. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9801. }
  9802. }
  9803. declare module BABYLON {
  9804. /**
  9805. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9806. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9807. * 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.
  9808. */
  9809. export abstract class Light extends Node {
  9810. /**
  9811. * Falloff Default: light is falling off following the material specification:
  9812. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9813. */
  9814. static readonly FALLOFF_DEFAULT: number;
  9815. /**
  9816. * Falloff Physical: light is falling off following the inverse squared distance law.
  9817. */
  9818. static readonly FALLOFF_PHYSICAL: number;
  9819. /**
  9820. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9821. * to enhance interoperability with other engines.
  9822. */
  9823. static readonly FALLOFF_GLTF: number;
  9824. /**
  9825. * Falloff Standard: light is falling off like in the standard material
  9826. * to enhance interoperability with other materials.
  9827. */
  9828. static readonly FALLOFF_STANDARD: number;
  9829. /**
  9830. * If every light affecting the material is in this lightmapMode,
  9831. * material.lightmapTexture adds or multiplies
  9832. * (depends on material.useLightmapAsShadowmap)
  9833. * after every other light calculations.
  9834. */
  9835. static readonly LIGHTMAP_DEFAULT: number;
  9836. /**
  9837. * material.lightmapTexture as only diffuse lighting from this light
  9838. * adds only specular lighting from this light
  9839. * adds dynamic shadows
  9840. */
  9841. static readonly LIGHTMAP_SPECULAR: number;
  9842. /**
  9843. * material.lightmapTexture as only lighting
  9844. * no light calculation from this light
  9845. * only adds dynamic shadows from this light
  9846. */
  9847. static readonly LIGHTMAP_SHADOWSONLY: number;
  9848. /**
  9849. * Each light type uses the default quantity according to its type:
  9850. * point/spot lights use luminous intensity
  9851. * directional lights use illuminance
  9852. */
  9853. static readonly INTENSITYMODE_AUTOMATIC: number;
  9854. /**
  9855. * lumen (lm)
  9856. */
  9857. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9858. /**
  9859. * candela (lm/sr)
  9860. */
  9861. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9862. /**
  9863. * lux (lm/m^2)
  9864. */
  9865. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9866. /**
  9867. * nit (cd/m^2)
  9868. */
  9869. static readonly INTENSITYMODE_LUMINANCE: number;
  9870. /**
  9871. * Light type const id of the point light.
  9872. */
  9873. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9874. /**
  9875. * Light type const id of the directional light.
  9876. */
  9877. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9878. /**
  9879. * Light type const id of the spot light.
  9880. */
  9881. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9882. /**
  9883. * Light type const id of the hemispheric light.
  9884. */
  9885. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9886. /**
  9887. * Diffuse gives the basic color to an object.
  9888. */
  9889. diffuse: Color3;
  9890. /**
  9891. * Specular produces a highlight color on an object.
  9892. * Note: This is note affecting PBR materials.
  9893. */
  9894. specular: Color3;
  9895. /**
  9896. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9897. * falling off base on range or angle.
  9898. * This can be set to any values in Light.FALLOFF_x.
  9899. *
  9900. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9901. * other types of materials.
  9902. */
  9903. falloffType: number;
  9904. /**
  9905. * Strength of the light.
  9906. * Note: By default it is define in the framework own unit.
  9907. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9908. */
  9909. intensity: number;
  9910. private _range;
  9911. protected _inverseSquaredRange: number;
  9912. /**
  9913. * Defines how far from the source the light is impacting in scene units.
  9914. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9915. */
  9916. /**
  9917. * Defines how far from the source the light is impacting in scene units.
  9918. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9919. */
  9920. range: number;
  9921. /**
  9922. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9923. * of light.
  9924. */
  9925. private _photometricScale;
  9926. private _intensityMode;
  9927. /**
  9928. * Gets the photometric scale used to interpret the intensity.
  9929. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9930. */
  9931. /**
  9932. * Sets the photometric scale used to interpret the intensity.
  9933. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9934. */
  9935. intensityMode: number;
  9936. private _radius;
  9937. /**
  9938. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9939. */
  9940. /**
  9941. * sets the light radius used by PBR Materials to simulate soft area lights.
  9942. */
  9943. radius: number;
  9944. private _renderPriority;
  9945. /**
  9946. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9947. * exceeding the number allowed of the materials.
  9948. */
  9949. renderPriority: number;
  9950. private _shadowEnabled;
  9951. /**
  9952. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9953. * the current shadow generator.
  9954. */
  9955. /**
  9956. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9957. * the current shadow generator.
  9958. */
  9959. shadowEnabled: boolean;
  9960. private _includedOnlyMeshes;
  9961. /**
  9962. * Gets the only meshes impacted by this light.
  9963. */
  9964. /**
  9965. * Sets the only meshes impacted by this light.
  9966. */
  9967. includedOnlyMeshes: AbstractMesh[];
  9968. private _excludedMeshes;
  9969. /**
  9970. * Gets the meshes not impacted by this light.
  9971. */
  9972. /**
  9973. * Sets the meshes not impacted by this light.
  9974. */
  9975. excludedMeshes: AbstractMesh[];
  9976. private _excludeWithLayerMask;
  9977. /**
  9978. * Gets the layer id use to find what meshes are not impacted by the light.
  9979. * Inactive if 0
  9980. */
  9981. /**
  9982. * Sets the layer id use to find what meshes are not impacted by the light.
  9983. * Inactive if 0
  9984. */
  9985. excludeWithLayerMask: number;
  9986. private _includeOnlyWithLayerMask;
  9987. /**
  9988. * Gets the layer id use to find what meshes are impacted by the light.
  9989. * Inactive if 0
  9990. */
  9991. /**
  9992. * Sets the layer id use to find what meshes are impacted by the light.
  9993. * Inactive if 0
  9994. */
  9995. includeOnlyWithLayerMask: number;
  9996. private _lightmapMode;
  9997. /**
  9998. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9999. */
  10000. /**
  10001. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10002. */
  10003. lightmapMode: number;
  10004. /**
  10005. * Shadow generator associted to the light.
  10006. * @hidden Internal use only.
  10007. */
  10008. _shadowGenerator: Nullable<IShadowGenerator>;
  10009. /**
  10010. * @hidden Internal use only.
  10011. */
  10012. _excludedMeshesIds: string[];
  10013. /**
  10014. * @hidden Internal use only.
  10015. */
  10016. _includedOnlyMeshesIds: string[];
  10017. /**
  10018. * The current light unifom buffer.
  10019. * @hidden Internal use only.
  10020. */
  10021. _uniformBuffer: UniformBuffer;
  10022. /**
  10023. * Creates a Light object in the scene.
  10024. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10025. * @param name The firendly name of the light
  10026. * @param scene The scene the light belongs too
  10027. */
  10028. constructor(name: string, scene: Scene);
  10029. protected abstract _buildUniformLayout(): void;
  10030. /**
  10031. * Sets the passed Effect "effect" with the Light information.
  10032. * @param effect The effect to update
  10033. * @param lightIndex The index of the light in the effect to update
  10034. * @returns The light
  10035. */
  10036. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10037. /**
  10038. * Sets the passed Effect "effect" with the Light information.
  10039. * @param effect The effect to update
  10040. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10041. * @returns The light
  10042. */
  10043. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10044. /**
  10045. * Returns the string "Light".
  10046. * @returns the class name
  10047. */
  10048. getClassName(): string;
  10049. /** @hidden */
  10050. readonly _isLight: boolean;
  10051. /**
  10052. * Converts the light information to a readable string for debug purpose.
  10053. * @param fullDetails Supports for multiple levels of logging within scene loading
  10054. * @returns the human readable light info
  10055. */
  10056. toString(fullDetails?: boolean): string;
  10057. /** @hidden */
  10058. protected _syncParentEnabledState(): void;
  10059. /**
  10060. * Set the enabled state of this node.
  10061. * @param value - the new enabled state
  10062. */
  10063. setEnabled(value: boolean): void;
  10064. /**
  10065. * Returns the Light associated shadow generator if any.
  10066. * @return the associated shadow generator.
  10067. */
  10068. getShadowGenerator(): Nullable<IShadowGenerator>;
  10069. /**
  10070. * Returns a Vector3, the absolute light position in the World.
  10071. * @returns the world space position of the light
  10072. */
  10073. getAbsolutePosition(): Vector3;
  10074. /**
  10075. * Specifies if the light will affect the passed mesh.
  10076. * @param mesh The mesh to test against the light
  10077. * @return true the mesh is affected otherwise, false.
  10078. */
  10079. canAffectMesh(mesh: AbstractMesh): boolean;
  10080. /**
  10081. * Sort function to order lights for rendering.
  10082. * @param a First Light object to compare to second.
  10083. * @param b Second Light object to compare first.
  10084. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10085. */
  10086. static CompareLightsPriority(a: Light, b: Light): number;
  10087. /**
  10088. * Releases resources associated with this node.
  10089. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10090. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10091. */
  10092. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10093. /**
  10094. * Returns the light type ID (integer).
  10095. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10096. */
  10097. getTypeID(): number;
  10098. /**
  10099. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10100. * @returns the scaled intensity in intensity mode unit
  10101. */
  10102. getScaledIntensity(): number;
  10103. /**
  10104. * Returns a new Light object, named "name", from the current one.
  10105. * @param name The name of the cloned light
  10106. * @returns the new created light
  10107. */
  10108. clone(name: string): Nullable<Light>;
  10109. /**
  10110. * Serializes the current light into a Serialization object.
  10111. * @returns the serialized object.
  10112. */
  10113. serialize(): any;
  10114. /**
  10115. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10116. * This new light is named "name" and added to the passed scene.
  10117. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10118. * @param name The friendly name of the light
  10119. * @param scene The scene the new light will belong to
  10120. * @returns the constructor function
  10121. */
  10122. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10123. /**
  10124. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10125. * @param parsedLight The JSON representation of the light
  10126. * @param scene The scene to create the parsed light in
  10127. * @returns the created light after parsing
  10128. */
  10129. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10130. private _hookArrayForExcluded;
  10131. private _hookArrayForIncludedOnly;
  10132. private _resyncMeshes;
  10133. /**
  10134. * Forces the meshes to update their light related information in their rendering used effects
  10135. * @hidden Internal Use Only
  10136. */
  10137. _markMeshesAsLightDirty(): void;
  10138. /**
  10139. * Recomputes the cached photometric scale if needed.
  10140. */
  10141. private _computePhotometricScale;
  10142. /**
  10143. * Returns the Photometric Scale according to the light type and intensity mode.
  10144. */
  10145. private _getPhotometricScale;
  10146. /**
  10147. * Reorder the light in the scene according to their defined priority.
  10148. * @hidden Internal Use Only
  10149. */
  10150. _reorderLightsInScene(): void;
  10151. /**
  10152. * Prepares the list of defines specific to the light type.
  10153. * @param defines the list of defines
  10154. * @param lightIndex defines the index of the light for the effect
  10155. */
  10156. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10157. }
  10158. }
  10159. declare module BABYLON {
  10160. /**
  10161. * Interface used to define Action
  10162. */
  10163. export interface IAction {
  10164. /**
  10165. * Trigger for the action
  10166. */
  10167. trigger: number;
  10168. /** Options of the trigger */
  10169. triggerOptions: any;
  10170. /**
  10171. * Gets the trigger parameters
  10172. * @returns the trigger parameters
  10173. */
  10174. getTriggerParameter(): any;
  10175. /**
  10176. * Internal only - executes current action event
  10177. * @hidden
  10178. */
  10179. _executeCurrent(evt?: ActionEvent): void;
  10180. /**
  10181. * Serialize placeholder for child classes
  10182. * @param parent of child
  10183. * @returns the serialized object
  10184. */
  10185. serialize(parent: any): any;
  10186. /**
  10187. * Internal only
  10188. * @hidden
  10189. */
  10190. _prepare(): void;
  10191. /**
  10192. * Internal only - manager for action
  10193. * @hidden
  10194. */
  10195. _actionManager: AbstractActionManager;
  10196. /**
  10197. * Adds action to chain of actions, may be a DoNothingAction
  10198. * @param action defines the next action to execute
  10199. * @returns The action passed in
  10200. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10201. */
  10202. then(action: IAction): IAction;
  10203. }
  10204. /**
  10205. * The action to be carried out following a trigger
  10206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10207. */
  10208. export class Action implements IAction {
  10209. /** the trigger, with or without parameters, for the action */
  10210. triggerOptions: any;
  10211. /**
  10212. * Trigger for the action
  10213. */
  10214. trigger: number;
  10215. /**
  10216. * Internal only - manager for action
  10217. * @hidden
  10218. */
  10219. _actionManager: ActionManager;
  10220. private _nextActiveAction;
  10221. private _child;
  10222. private _condition?;
  10223. private _triggerParameter;
  10224. /**
  10225. * An event triggered prior to action being executed.
  10226. */
  10227. onBeforeExecuteObservable: Observable<Action>;
  10228. /**
  10229. * Creates a new Action
  10230. * @param triggerOptions the trigger, with or without parameters, for the action
  10231. * @param condition an optional determinant of action
  10232. */
  10233. constructor(
  10234. /** the trigger, with or without parameters, for the action */
  10235. triggerOptions: any, condition?: Condition);
  10236. /**
  10237. * Internal only
  10238. * @hidden
  10239. */
  10240. _prepare(): void;
  10241. /**
  10242. * Gets the trigger parameters
  10243. * @returns the trigger parameters
  10244. */
  10245. getTriggerParameter(): any;
  10246. /**
  10247. * Internal only - executes current action event
  10248. * @hidden
  10249. */
  10250. _executeCurrent(evt?: ActionEvent): void;
  10251. /**
  10252. * Execute placeholder for child classes
  10253. * @param evt optional action event
  10254. */
  10255. execute(evt?: ActionEvent): void;
  10256. /**
  10257. * Skips to next active action
  10258. */
  10259. skipToNextActiveAction(): void;
  10260. /**
  10261. * Adds action to chain of actions, may be a DoNothingAction
  10262. * @param action defines the next action to execute
  10263. * @returns The action passed in
  10264. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10265. */
  10266. then(action: Action): Action;
  10267. /**
  10268. * Internal only
  10269. * @hidden
  10270. */
  10271. _getProperty(propertyPath: string): string;
  10272. /**
  10273. * Internal only
  10274. * @hidden
  10275. */
  10276. _getEffectiveTarget(target: any, propertyPath: string): any;
  10277. /**
  10278. * Serialize placeholder for child classes
  10279. * @param parent of child
  10280. * @returns the serialized object
  10281. */
  10282. serialize(parent: any): any;
  10283. /**
  10284. * Internal only called by serialize
  10285. * @hidden
  10286. */
  10287. protected _serialize(serializedAction: any, parent?: any): any;
  10288. /**
  10289. * Internal only
  10290. * @hidden
  10291. */
  10292. static _SerializeValueAsString: (value: any) => string;
  10293. /**
  10294. * Internal only
  10295. * @hidden
  10296. */
  10297. static _GetTargetProperty: (target: Node | Scene) => {
  10298. name: string;
  10299. targetType: string;
  10300. value: string;
  10301. };
  10302. }
  10303. }
  10304. declare module BABYLON {
  10305. /**
  10306. * A Condition applied to an Action
  10307. */
  10308. export class Condition {
  10309. /**
  10310. * Internal only - manager for action
  10311. * @hidden
  10312. */
  10313. _actionManager: ActionManager;
  10314. /**
  10315. * Internal only
  10316. * @hidden
  10317. */
  10318. _evaluationId: number;
  10319. /**
  10320. * Internal only
  10321. * @hidden
  10322. */
  10323. _currentResult: boolean;
  10324. /**
  10325. * Creates a new Condition
  10326. * @param actionManager the manager of the action the condition is applied to
  10327. */
  10328. constructor(actionManager: ActionManager);
  10329. /**
  10330. * Check if the current condition is valid
  10331. * @returns a boolean
  10332. */
  10333. isValid(): boolean;
  10334. /**
  10335. * Internal only
  10336. * @hidden
  10337. */
  10338. _getProperty(propertyPath: string): string;
  10339. /**
  10340. * Internal only
  10341. * @hidden
  10342. */
  10343. _getEffectiveTarget(target: any, propertyPath: string): any;
  10344. /**
  10345. * Serialize placeholder for child classes
  10346. * @returns the serialized object
  10347. */
  10348. serialize(): any;
  10349. /**
  10350. * Internal only
  10351. * @hidden
  10352. */
  10353. protected _serialize(serializedCondition: any): any;
  10354. }
  10355. /**
  10356. * Defines specific conditional operators as extensions of Condition
  10357. */
  10358. export class ValueCondition extends Condition {
  10359. /** path to specify the property of the target the conditional operator uses */
  10360. propertyPath: string;
  10361. /** the value compared by the conditional operator against the current value of the property */
  10362. value: any;
  10363. /** the conditional operator, default ValueCondition.IsEqual */
  10364. operator: number;
  10365. /**
  10366. * Internal only
  10367. * @hidden
  10368. */
  10369. private static _IsEqual;
  10370. /**
  10371. * Internal only
  10372. * @hidden
  10373. */
  10374. private static _IsDifferent;
  10375. /**
  10376. * Internal only
  10377. * @hidden
  10378. */
  10379. private static _IsGreater;
  10380. /**
  10381. * Internal only
  10382. * @hidden
  10383. */
  10384. private static _IsLesser;
  10385. /**
  10386. * returns the number for IsEqual
  10387. */
  10388. static readonly IsEqual: number;
  10389. /**
  10390. * Returns the number for IsDifferent
  10391. */
  10392. static readonly IsDifferent: number;
  10393. /**
  10394. * Returns the number for IsGreater
  10395. */
  10396. static readonly IsGreater: number;
  10397. /**
  10398. * Returns the number for IsLesser
  10399. */
  10400. static readonly IsLesser: number;
  10401. /**
  10402. * Internal only The action manager for the condition
  10403. * @hidden
  10404. */
  10405. _actionManager: ActionManager;
  10406. /**
  10407. * Internal only
  10408. * @hidden
  10409. */
  10410. private _target;
  10411. /**
  10412. * Internal only
  10413. * @hidden
  10414. */
  10415. private _effectiveTarget;
  10416. /**
  10417. * Internal only
  10418. * @hidden
  10419. */
  10420. private _property;
  10421. /**
  10422. * Creates a new ValueCondition
  10423. * @param actionManager manager for the action the condition applies to
  10424. * @param target for the action
  10425. * @param propertyPath path to specify the property of the target the conditional operator uses
  10426. * @param value the value compared by the conditional operator against the current value of the property
  10427. * @param operator the conditional operator, default ValueCondition.IsEqual
  10428. */
  10429. constructor(actionManager: ActionManager, target: any,
  10430. /** path to specify the property of the target the conditional operator uses */
  10431. propertyPath: string,
  10432. /** the value compared by the conditional operator against the current value of the property */
  10433. value: any,
  10434. /** the conditional operator, default ValueCondition.IsEqual */
  10435. operator?: number);
  10436. /**
  10437. * Compares the given value with the property value for the specified conditional operator
  10438. * @returns the result of the comparison
  10439. */
  10440. isValid(): boolean;
  10441. /**
  10442. * Serialize the ValueCondition into a JSON compatible object
  10443. * @returns serialization object
  10444. */
  10445. serialize(): any;
  10446. /**
  10447. * Gets the name of the conditional operator for the ValueCondition
  10448. * @param operator the conditional operator
  10449. * @returns the name
  10450. */
  10451. static GetOperatorName(operator: number): string;
  10452. }
  10453. /**
  10454. * Defines a predicate condition as an extension of Condition
  10455. */
  10456. export class PredicateCondition extends Condition {
  10457. /** defines the predicate function used to validate the condition */
  10458. predicate: () => boolean;
  10459. /**
  10460. * Internal only - manager for action
  10461. * @hidden
  10462. */
  10463. _actionManager: ActionManager;
  10464. /**
  10465. * Creates a new PredicateCondition
  10466. * @param actionManager manager for the action the condition applies to
  10467. * @param predicate defines the predicate function used to validate the condition
  10468. */
  10469. constructor(actionManager: ActionManager,
  10470. /** defines the predicate function used to validate the condition */
  10471. predicate: () => boolean);
  10472. /**
  10473. * @returns the validity of the predicate condition
  10474. */
  10475. isValid(): boolean;
  10476. }
  10477. /**
  10478. * Defines a state condition as an extension of Condition
  10479. */
  10480. export class StateCondition extends Condition {
  10481. /** Value to compare with target state */
  10482. value: string;
  10483. /**
  10484. * Internal only - manager for action
  10485. * @hidden
  10486. */
  10487. _actionManager: ActionManager;
  10488. /**
  10489. * Internal only
  10490. * @hidden
  10491. */
  10492. private _target;
  10493. /**
  10494. * Creates a new StateCondition
  10495. * @param actionManager manager for the action the condition applies to
  10496. * @param target of the condition
  10497. * @param value to compare with target state
  10498. */
  10499. constructor(actionManager: ActionManager, target: any,
  10500. /** Value to compare with target state */
  10501. value: string);
  10502. /**
  10503. * Gets a boolean indicating if the current condition is met
  10504. * @returns the validity of the state
  10505. */
  10506. isValid(): boolean;
  10507. /**
  10508. * Serialize the StateCondition into a JSON compatible object
  10509. * @returns serialization object
  10510. */
  10511. serialize(): any;
  10512. }
  10513. }
  10514. declare module BABYLON {
  10515. /**
  10516. * This defines an action responsible to toggle a boolean once triggered.
  10517. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10518. */
  10519. export class SwitchBooleanAction extends Action {
  10520. /**
  10521. * The path to the boolean property in the target object
  10522. */
  10523. propertyPath: string;
  10524. private _target;
  10525. private _effectiveTarget;
  10526. private _property;
  10527. /**
  10528. * Instantiate the action
  10529. * @param triggerOptions defines the trigger options
  10530. * @param target defines the object containing the boolean
  10531. * @param propertyPath defines the path to the boolean property in the target object
  10532. * @param condition defines the trigger related conditions
  10533. */
  10534. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10535. /** @hidden */
  10536. _prepare(): void;
  10537. /**
  10538. * Execute the action toggle the boolean value.
  10539. */
  10540. execute(): void;
  10541. /**
  10542. * Serializes the actions and its related information.
  10543. * @param parent defines the object to serialize in
  10544. * @returns the serialized object
  10545. */
  10546. serialize(parent: any): any;
  10547. }
  10548. /**
  10549. * This defines an action responsible to set a the state field of the target
  10550. * to a desired value once triggered.
  10551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10552. */
  10553. export class SetStateAction extends Action {
  10554. /**
  10555. * The value to store in the state field.
  10556. */
  10557. value: string;
  10558. private _target;
  10559. /**
  10560. * Instantiate the action
  10561. * @param triggerOptions defines the trigger options
  10562. * @param target defines the object containing the state property
  10563. * @param value defines the value to store in the state field
  10564. * @param condition defines the trigger related conditions
  10565. */
  10566. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10567. /**
  10568. * Execute the action and store the value on the target state property.
  10569. */
  10570. execute(): void;
  10571. /**
  10572. * Serializes the actions and its related information.
  10573. * @param parent defines the object to serialize in
  10574. * @returns the serialized object
  10575. */
  10576. serialize(parent: any): any;
  10577. }
  10578. /**
  10579. * This defines an action responsible to set a property of the target
  10580. * to a desired value once triggered.
  10581. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10582. */
  10583. export class SetValueAction extends Action {
  10584. /**
  10585. * The path of the property to set in the target.
  10586. */
  10587. propertyPath: string;
  10588. /**
  10589. * The value to set in the property
  10590. */
  10591. value: any;
  10592. private _target;
  10593. private _effectiveTarget;
  10594. private _property;
  10595. /**
  10596. * Instantiate the action
  10597. * @param triggerOptions defines the trigger options
  10598. * @param target defines the object containing the property
  10599. * @param propertyPath defines the path of the property to set in the target
  10600. * @param value defines the value to set in the property
  10601. * @param condition defines the trigger related conditions
  10602. */
  10603. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10604. /** @hidden */
  10605. _prepare(): void;
  10606. /**
  10607. * Execute the action and set the targetted property to the desired value.
  10608. */
  10609. execute(): void;
  10610. /**
  10611. * Serializes the actions and its related information.
  10612. * @param parent defines the object to serialize in
  10613. * @returns the serialized object
  10614. */
  10615. serialize(parent: any): any;
  10616. }
  10617. /**
  10618. * This defines an action responsible to increment the target value
  10619. * to a desired value once triggered.
  10620. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10621. */
  10622. export class IncrementValueAction extends Action {
  10623. /**
  10624. * The path of the property to increment in the target.
  10625. */
  10626. propertyPath: string;
  10627. /**
  10628. * The value we should increment the property by.
  10629. */
  10630. value: any;
  10631. private _target;
  10632. private _effectiveTarget;
  10633. private _property;
  10634. /**
  10635. * Instantiate the action
  10636. * @param triggerOptions defines the trigger options
  10637. * @param target defines the object containing the property
  10638. * @param propertyPath defines the path of the property to increment in the target
  10639. * @param value defines the value value we should increment the property by
  10640. * @param condition defines the trigger related conditions
  10641. */
  10642. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10643. /** @hidden */
  10644. _prepare(): void;
  10645. /**
  10646. * Execute the action and increment the target of the value amount.
  10647. */
  10648. execute(): void;
  10649. /**
  10650. * Serializes the actions and its related information.
  10651. * @param parent defines the object to serialize in
  10652. * @returns the serialized object
  10653. */
  10654. serialize(parent: any): any;
  10655. }
  10656. /**
  10657. * This defines an action responsible to start an animation once triggered.
  10658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10659. */
  10660. export class PlayAnimationAction extends Action {
  10661. /**
  10662. * Where the animation should start (animation frame)
  10663. */
  10664. from: number;
  10665. /**
  10666. * Where the animation should stop (animation frame)
  10667. */
  10668. to: number;
  10669. /**
  10670. * Define if the animation should loop or stop after the first play.
  10671. */
  10672. loop?: boolean;
  10673. private _target;
  10674. /**
  10675. * Instantiate the action
  10676. * @param triggerOptions defines the trigger options
  10677. * @param target defines the target animation or animation name
  10678. * @param from defines from where the animation should start (animation frame)
  10679. * @param end defines where the animation should stop (animation frame)
  10680. * @param loop defines if the animation should loop or stop after the first play
  10681. * @param condition defines the trigger related conditions
  10682. */
  10683. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10684. /** @hidden */
  10685. _prepare(): void;
  10686. /**
  10687. * Execute the action and play the animation.
  10688. */
  10689. execute(): void;
  10690. /**
  10691. * Serializes the actions and its related information.
  10692. * @param parent defines the object to serialize in
  10693. * @returns the serialized object
  10694. */
  10695. serialize(parent: any): any;
  10696. }
  10697. /**
  10698. * This defines an action responsible to stop an animation once triggered.
  10699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10700. */
  10701. export class StopAnimationAction extends Action {
  10702. private _target;
  10703. /**
  10704. * Instantiate the action
  10705. * @param triggerOptions defines the trigger options
  10706. * @param target defines the target animation or animation name
  10707. * @param condition defines the trigger related conditions
  10708. */
  10709. constructor(triggerOptions: any, target: any, condition?: Condition);
  10710. /** @hidden */
  10711. _prepare(): void;
  10712. /**
  10713. * Execute the action and stop the animation.
  10714. */
  10715. execute(): void;
  10716. /**
  10717. * Serializes the actions and its related information.
  10718. * @param parent defines the object to serialize in
  10719. * @returns the serialized object
  10720. */
  10721. serialize(parent: any): any;
  10722. }
  10723. /**
  10724. * This defines an action responsible that does nothing once triggered.
  10725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10726. */
  10727. export class DoNothingAction extends Action {
  10728. /**
  10729. * Instantiate the action
  10730. * @param triggerOptions defines the trigger options
  10731. * @param condition defines the trigger related conditions
  10732. */
  10733. constructor(triggerOptions?: any, condition?: Condition);
  10734. /**
  10735. * Execute the action and do nothing.
  10736. */
  10737. execute(): void;
  10738. /**
  10739. * Serializes the actions and its related information.
  10740. * @param parent defines the object to serialize in
  10741. * @returns the serialized object
  10742. */
  10743. serialize(parent: any): any;
  10744. }
  10745. /**
  10746. * This defines an action responsible to trigger several actions once triggered.
  10747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10748. */
  10749. export class CombineAction extends Action {
  10750. /**
  10751. * The list of aggregated animations to run.
  10752. */
  10753. children: Action[];
  10754. /**
  10755. * Instantiate the action
  10756. * @param triggerOptions defines the trigger options
  10757. * @param children defines the list of aggregated animations to run
  10758. * @param condition defines the trigger related conditions
  10759. */
  10760. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10761. /** @hidden */
  10762. _prepare(): void;
  10763. /**
  10764. * Execute the action and executes all the aggregated actions.
  10765. */
  10766. execute(evt: ActionEvent): void;
  10767. /**
  10768. * Serializes the actions and its related information.
  10769. * @param parent defines the object to serialize in
  10770. * @returns the serialized object
  10771. */
  10772. serialize(parent: any): any;
  10773. }
  10774. /**
  10775. * This defines an action responsible to run code (external event) once triggered.
  10776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10777. */
  10778. export class ExecuteCodeAction extends Action {
  10779. /**
  10780. * The callback function to run.
  10781. */
  10782. func: (evt: ActionEvent) => void;
  10783. /**
  10784. * Instantiate the action
  10785. * @param triggerOptions defines the trigger options
  10786. * @param func defines the callback function to run
  10787. * @param condition defines the trigger related conditions
  10788. */
  10789. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10790. /**
  10791. * Execute the action and run the attached code.
  10792. */
  10793. execute(evt: ActionEvent): void;
  10794. }
  10795. /**
  10796. * This defines an action responsible to set the parent property of the target once triggered.
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10798. */
  10799. export class SetParentAction extends Action {
  10800. private _parent;
  10801. private _target;
  10802. /**
  10803. * Instantiate the action
  10804. * @param triggerOptions defines the trigger options
  10805. * @param target defines the target containing the parent property
  10806. * @param parent defines from where the animation should start (animation frame)
  10807. * @param condition defines the trigger related conditions
  10808. */
  10809. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10810. /** @hidden */
  10811. _prepare(): void;
  10812. /**
  10813. * Execute the action and set the parent property.
  10814. */
  10815. execute(): void;
  10816. /**
  10817. * Serializes the actions and its related information.
  10818. * @param parent defines the object to serialize in
  10819. * @returns the serialized object
  10820. */
  10821. serialize(parent: any): any;
  10822. }
  10823. }
  10824. declare module BABYLON {
  10825. /**
  10826. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10827. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10829. */
  10830. export class ActionManager extends AbstractActionManager {
  10831. /**
  10832. * Nothing
  10833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10834. */
  10835. static readonly NothingTrigger: number;
  10836. /**
  10837. * On pick
  10838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10839. */
  10840. static readonly OnPickTrigger: number;
  10841. /**
  10842. * On left pick
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10844. */
  10845. static readonly OnLeftPickTrigger: number;
  10846. /**
  10847. * On right pick
  10848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10849. */
  10850. static readonly OnRightPickTrigger: number;
  10851. /**
  10852. * On center pick
  10853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10854. */
  10855. static readonly OnCenterPickTrigger: number;
  10856. /**
  10857. * On pick down
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10859. */
  10860. static readonly OnPickDownTrigger: number;
  10861. /**
  10862. * On double pick
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10864. */
  10865. static readonly OnDoublePickTrigger: number;
  10866. /**
  10867. * On pick up
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10869. */
  10870. static readonly OnPickUpTrigger: number;
  10871. /**
  10872. * On pick out.
  10873. * This trigger will only be raised if you also declared a OnPickDown
  10874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10875. */
  10876. static readonly OnPickOutTrigger: number;
  10877. /**
  10878. * On long press
  10879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10880. */
  10881. static readonly OnLongPressTrigger: number;
  10882. /**
  10883. * On pointer over
  10884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10885. */
  10886. static readonly OnPointerOverTrigger: number;
  10887. /**
  10888. * On pointer out
  10889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10890. */
  10891. static readonly OnPointerOutTrigger: number;
  10892. /**
  10893. * On every frame
  10894. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10895. */
  10896. static readonly OnEveryFrameTrigger: number;
  10897. /**
  10898. * On intersection enter
  10899. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10900. */
  10901. static readonly OnIntersectionEnterTrigger: number;
  10902. /**
  10903. * On intersection exit
  10904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10905. */
  10906. static readonly OnIntersectionExitTrigger: number;
  10907. /**
  10908. * On key down
  10909. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10910. */
  10911. static readonly OnKeyDownTrigger: number;
  10912. /**
  10913. * On key up
  10914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10915. */
  10916. static readonly OnKeyUpTrigger: number;
  10917. private _scene;
  10918. /**
  10919. * Creates a new action manager
  10920. * @param scene defines the hosting scene
  10921. */
  10922. constructor(scene: Scene);
  10923. /**
  10924. * Releases all associated resources
  10925. */
  10926. dispose(): void;
  10927. /**
  10928. * Gets hosting scene
  10929. * @returns the hosting scene
  10930. */
  10931. getScene(): Scene;
  10932. /**
  10933. * Does this action manager handles actions of any of the given triggers
  10934. * @param triggers defines the triggers to be tested
  10935. * @return a boolean indicating whether one (or more) of the triggers is handled
  10936. */
  10937. hasSpecificTriggers(triggers: number[]): boolean;
  10938. /**
  10939. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10940. * speed.
  10941. * @param triggerA defines the trigger to be tested
  10942. * @param triggerB defines the trigger to be tested
  10943. * @return a boolean indicating whether one (or more) of the triggers is handled
  10944. */
  10945. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10946. /**
  10947. * Does this action manager handles actions of a given trigger
  10948. * @param trigger defines the trigger to be tested
  10949. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10950. * @return whether the trigger is handled
  10951. */
  10952. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10953. /**
  10954. * Does this action manager has pointer triggers
  10955. */
  10956. readonly hasPointerTriggers: boolean;
  10957. /**
  10958. * Does this action manager has pick triggers
  10959. */
  10960. readonly hasPickTriggers: boolean;
  10961. /**
  10962. * Registers an action to this action manager
  10963. * @param action defines the action to be registered
  10964. * @return the action amended (prepared) after registration
  10965. */
  10966. registerAction(action: IAction): Nullable<IAction>;
  10967. /**
  10968. * Unregisters an action to this action manager
  10969. * @param action defines the action to be unregistered
  10970. * @return a boolean indicating whether the action has been unregistered
  10971. */
  10972. unregisterAction(action: IAction): Boolean;
  10973. /**
  10974. * Process a specific trigger
  10975. * @param trigger defines the trigger to process
  10976. * @param evt defines the event details to be processed
  10977. */
  10978. processTrigger(trigger: number, evt?: IActionEvent): void;
  10979. /** @hidden */
  10980. _getEffectiveTarget(target: any, propertyPath: string): any;
  10981. /** @hidden */
  10982. _getProperty(propertyPath: string): string;
  10983. /**
  10984. * Serialize this manager to a JSON object
  10985. * @param name defines the property name to store this manager
  10986. * @returns a JSON representation of this manager
  10987. */
  10988. serialize(name: string): any;
  10989. /**
  10990. * Creates a new ActionManager from a JSON data
  10991. * @param parsedActions defines the JSON data to read from
  10992. * @param object defines the hosting mesh
  10993. * @param scene defines the hosting scene
  10994. */
  10995. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10996. /**
  10997. * Get a trigger name by index
  10998. * @param trigger defines the trigger index
  10999. * @returns a trigger name
  11000. */
  11001. static GetTriggerName(trigger: number): string;
  11002. }
  11003. }
  11004. declare module BABYLON {
  11005. /**
  11006. * Class representing a ray with position and direction
  11007. */
  11008. export class Ray {
  11009. /** origin point */
  11010. origin: Vector3;
  11011. /** direction */
  11012. direction: Vector3;
  11013. /** length of the ray */
  11014. length: number;
  11015. private static readonly TmpVector3;
  11016. private _tmpRay;
  11017. /**
  11018. * Creates a new ray
  11019. * @param origin origin point
  11020. * @param direction direction
  11021. * @param length length of the ray
  11022. */
  11023. constructor(
  11024. /** origin point */
  11025. origin: Vector3,
  11026. /** direction */
  11027. direction: Vector3,
  11028. /** length of the ray */
  11029. length?: number);
  11030. /**
  11031. * Checks if the ray intersects a box
  11032. * @param minimum bound of the box
  11033. * @param maximum bound of the box
  11034. * @param intersectionTreshold extra extend to be added to the box in all direction
  11035. * @returns if the box was hit
  11036. */
  11037. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11038. /**
  11039. * Checks if the ray intersects a box
  11040. * @param box the bounding box to check
  11041. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11042. * @returns if the box was hit
  11043. */
  11044. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11045. /**
  11046. * If the ray hits a sphere
  11047. * @param sphere the bounding sphere to check
  11048. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11049. * @returns true if it hits the sphere
  11050. */
  11051. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11052. /**
  11053. * If the ray hits a triange
  11054. * @param vertex0 triangle vertex
  11055. * @param vertex1 triangle vertex
  11056. * @param vertex2 triangle vertex
  11057. * @returns intersection information if hit
  11058. */
  11059. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11060. /**
  11061. * Checks if ray intersects a plane
  11062. * @param plane the plane to check
  11063. * @returns the distance away it was hit
  11064. */
  11065. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11066. /**
  11067. * Calculate the intercept of a ray on a given axis
  11068. * @param axis to check 'x' | 'y' | 'z'
  11069. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11070. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11071. */
  11072. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11073. /**
  11074. * Checks if ray intersects a mesh
  11075. * @param mesh the mesh to check
  11076. * @param fastCheck if only the bounding box should checked
  11077. * @returns picking info of the intersecton
  11078. */
  11079. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11080. /**
  11081. * Checks if ray intersects a mesh
  11082. * @param meshes the meshes to check
  11083. * @param fastCheck if only the bounding box should checked
  11084. * @param results array to store result in
  11085. * @returns Array of picking infos
  11086. */
  11087. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11088. private _comparePickingInfo;
  11089. private static smallnum;
  11090. private static rayl;
  11091. /**
  11092. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11093. * @param sega the first point of the segment to test the intersection against
  11094. * @param segb the second point of the segment to test the intersection against
  11095. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11096. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11097. */
  11098. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11099. /**
  11100. * Update the ray from viewport position
  11101. * @param x position
  11102. * @param y y position
  11103. * @param viewportWidth viewport width
  11104. * @param viewportHeight viewport height
  11105. * @param world world matrix
  11106. * @param view view matrix
  11107. * @param projection projection matrix
  11108. * @returns this ray updated
  11109. */
  11110. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11111. /**
  11112. * Creates a ray with origin and direction of 0,0,0
  11113. * @returns the new ray
  11114. */
  11115. static Zero(): Ray;
  11116. /**
  11117. * Creates a new ray from screen space and viewport
  11118. * @param x position
  11119. * @param y y position
  11120. * @param viewportWidth viewport width
  11121. * @param viewportHeight viewport height
  11122. * @param world world matrix
  11123. * @param view view matrix
  11124. * @param projection projection matrix
  11125. * @returns new ray
  11126. */
  11127. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11128. /**
  11129. * 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
  11130. * transformed to the given world matrix.
  11131. * @param origin The origin point
  11132. * @param end The end point
  11133. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11134. * @returns the new ray
  11135. */
  11136. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11137. /**
  11138. * Transforms a ray by a matrix
  11139. * @param ray ray to transform
  11140. * @param matrix matrix to apply
  11141. * @returns the resulting new ray
  11142. */
  11143. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11144. /**
  11145. * Transforms a ray by a matrix
  11146. * @param ray ray to transform
  11147. * @param matrix matrix to apply
  11148. * @param result ray to store result in
  11149. */
  11150. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11151. /**
  11152. * Unproject a ray from screen space to object space
  11153. * @param sourceX defines the screen space x coordinate to use
  11154. * @param sourceY defines the screen space y coordinate to use
  11155. * @param viewportWidth defines the current width of the viewport
  11156. * @param viewportHeight defines the current height of the viewport
  11157. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11158. * @param view defines the view matrix to use
  11159. * @param projection defines the projection matrix to use
  11160. */
  11161. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11162. }
  11163. /**
  11164. * Type used to define predicate used to select faces when a mesh intersection is detected
  11165. */
  11166. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11167. interface Scene {
  11168. /** @hidden */
  11169. _tempPickingRay: Nullable<Ray>;
  11170. /** @hidden */
  11171. _cachedRayForTransform: Ray;
  11172. /** @hidden */
  11173. _pickWithRayInverseMatrix: Matrix;
  11174. /** @hidden */
  11175. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11176. /** @hidden */
  11177. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11178. }
  11179. }
  11180. declare module BABYLON {
  11181. /**
  11182. * Groups all the scene component constants in one place to ease maintenance.
  11183. * @hidden
  11184. */
  11185. export class SceneComponentConstants {
  11186. static readonly NAME_EFFECTLAYER: string;
  11187. static readonly NAME_LAYER: string;
  11188. static readonly NAME_LENSFLARESYSTEM: string;
  11189. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11190. static readonly NAME_PARTICLESYSTEM: string;
  11191. static readonly NAME_GAMEPAD: string;
  11192. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11193. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11194. static readonly NAME_DEPTHRENDERER: string;
  11195. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11196. static readonly NAME_SPRITE: string;
  11197. static readonly NAME_OUTLINERENDERER: string;
  11198. static readonly NAME_PROCEDURALTEXTURE: string;
  11199. static readonly NAME_SHADOWGENERATOR: string;
  11200. static readonly NAME_OCTREE: string;
  11201. static readonly NAME_PHYSICSENGINE: string;
  11202. static readonly NAME_AUDIO: string;
  11203. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11204. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11205. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11206. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11207. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11208. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11209. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11210. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11211. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11212. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11213. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11214. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11215. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11216. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11217. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11218. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11219. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11220. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11221. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11222. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11223. static readonly STEP_AFTERRENDER_AUDIO: number;
  11224. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11225. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11226. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11227. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11228. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11229. static readonly STEP_POINTERMOVE_SPRITE: number;
  11230. static readonly STEP_POINTERDOWN_SPRITE: number;
  11231. static readonly STEP_POINTERUP_SPRITE: number;
  11232. }
  11233. /**
  11234. * This represents a scene component.
  11235. *
  11236. * This is used to decouple the dependency the scene is having on the different workloads like
  11237. * layers, post processes...
  11238. */
  11239. export interface ISceneComponent {
  11240. /**
  11241. * The name of the component. Each component must have a unique name.
  11242. */
  11243. name: string;
  11244. /**
  11245. * The scene the component belongs to.
  11246. */
  11247. scene: Scene;
  11248. /**
  11249. * Register the component to one instance of a scene.
  11250. */
  11251. register(): void;
  11252. /**
  11253. * Rebuilds the elements related to this component in case of
  11254. * context lost for instance.
  11255. */
  11256. rebuild(): void;
  11257. /**
  11258. * Disposes the component and the associated ressources.
  11259. */
  11260. dispose(): void;
  11261. }
  11262. /**
  11263. * This represents a SERIALIZABLE scene component.
  11264. *
  11265. * This extends Scene Component to add Serialization methods on top.
  11266. */
  11267. export interface ISceneSerializableComponent extends ISceneComponent {
  11268. /**
  11269. * Adds all the elements from the container to the scene
  11270. * @param container the container holding the elements
  11271. */
  11272. addFromContainer(container: AbstractScene): void;
  11273. /**
  11274. * Removes all the elements in the container from the scene
  11275. * @param container contains the elements to remove
  11276. * @param dispose if the removed element should be disposed (default: false)
  11277. */
  11278. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11279. /**
  11280. * Serializes the component data to the specified json object
  11281. * @param serializationObject The object to serialize to
  11282. */
  11283. serialize(serializationObject: any): void;
  11284. }
  11285. /**
  11286. * Strong typing of a Mesh related stage step action
  11287. */
  11288. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11289. /**
  11290. * Strong typing of a Evaluate Sub Mesh related stage step action
  11291. */
  11292. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11293. /**
  11294. * Strong typing of a Active Mesh related stage step action
  11295. */
  11296. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11297. /**
  11298. * Strong typing of a Camera related stage step action
  11299. */
  11300. export type CameraStageAction = (camera: Camera) => void;
  11301. /**
  11302. * Strong typing of a Camera Frame buffer related stage step action
  11303. */
  11304. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11305. /**
  11306. * Strong typing of a Render Target related stage step action
  11307. */
  11308. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11309. /**
  11310. * Strong typing of a RenderingGroup related stage step action
  11311. */
  11312. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11313. /**
  11314. * Strong typing of a Mesh Render related stage step action
  11315. */
  11316. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11317. /**
  11318. * Strong typing of a simple stage step action
  11319. */
  11320. export type SimpleStageAction = () => void;
  11321. /**
  11322. * Strong typing of a render target action.
  11323. */
  11324. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11325. /**
  11326. * Strong typing of a pointer move action.
  11327. */
  11328. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11329. /**
  11330. * Strong typing of a pointer up/down action.
  11331. */
  11332. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11333. /**
  11334. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11335. * @hidden
  11336. */
  11337. export class Stage<T extends Function> extends Array<{
  11338. index: number;
  11339. component: ISceneComponent;
  11340. action: T;
  11341. }> {
  11342. /**
  11343. * Hide ctor from the rest of the world.
  11344. * @param items The items to add.
  11345. */
  11346. private constructor();
  11347. /**
  11348. * Creates a new Stage.
  11349. * @returns A new instance of a Stage
  11350. */
  11351. static Create<T extends Function>(): Stage<T>;
  11352. /**
  11353. * Registers a step in an ordered way in the targeted stage.
  11354. * @param index Defines the position to register the step in
  11355. * @param component Defines the component attached to the step
  11356. * @param action Defines the action to launch during the step
  11357. */
  11358. registerStep(index: number, component: ISceneComponent, action: T): void;
  11359. /**
  11360. * Clears all the steps from the stage.
  11361. */
  11362. clear(): void;
  11363. }
  11364. }
  11365. declare module BABYLON {
  11366. interface Scene {
  11367. /** @hidden */
  11368. _pointerOverSprite: Nullable<Sprite>;
  11369. /** @hidden */
  11370. _pickedDownSprite: Nullable<Sprite>;
  11371. /** @hidden */
  11372. _tempSpritePickingRay: Nullable<Ray>;
  11373. /**
  11374. * All of the sprite managers added to this scene
  11375. * @see http://doc.babylonjs.com/babylon101/sprites
  11376. */
  11377. spriteManagers: Array<ISpriteManager>;
  11378. /**
  11379. * An event triggered when sprites rendering is about to start
  11380. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11381. */
  11382. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11383. /**
  11384. * An event triggered when sprites rendering is done
  11385. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11386. */
  11387. onAfterSpritesRenderingObservable: Observable<Scene>;
  11388. /** @hidden */
  11389. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11390. /** Launch a ray to try to pick a sprite in the scene
  11391. * @param x position on screen
  11392. * @param y position on screen
  11393. * @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
  11394. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11395. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11396. * @returns a PickingInfo
  11397. */
  11398. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11399. /** Use the given ray to pick a sprite in the scene
  11400. * @param ray The ray (in world space) to use to pick meshes
  11401. * @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
  11402. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11403. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11404. * @returns a PickingInfo
  11405. */
  11406. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11407. /** @hidden */
  11408. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11409. /** Launch a ray to try to pick sprites in the scene
  11410. * @param x position on screen
  11411. * @param y position on screen
  11412. * @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
  11413. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11414. * @returns a PickingInfo array
  11415. */
  11416. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11417. /** Use the given ray to pick sprites in the scene
  11418. * @param ray The ray (in world space) to use to pick meshes
  11419. * @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
  11420. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11421. * @returns a PickingInfo array
  11422. */
  11423. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11424. /**
  11425. * Force the sprite under the pointer
  11426. * @param sprite defines the sprite to use
  11427. */
  11428. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11429. /**
  11430. * Gets the sprite under the pointer
  11431. * @returns a Sprite or null if no sprite is under the pointer
  11432. */
  11433. getPointerOverSprite(): Nullable<Sprite>;
  11434. }
  11435. /**
  11436. * Defines the sprite scene component responsible to manage sprites
  11437. * in a given scene.
  11438. */
  11439. export class SpriteSceneComponent implements ISceneComponent {
  11440. /**
  11441. * The component name helpfull to identify the component in the list of scene components.
  11442. */
  11443. readonly name: string;
  11444. /**
  11445. * The scene the component belongs to.
  11446. */
  11447. scene: Scene;
  11448. /** @hidden */
  11449. private _spritePredicate;
  11450. /**
  11451. * Creates a new instance of the component for the given scene
  11452. * @param scene Defines the scene to register the component in
  11453. */
  11454. constructor(scene: Scene);
  11455. /**
  11456. * Registers the component in a given scene
  11457. */
  11458. register(): void;
  11459. /**
  11460. * Rebuilds the elements related to this component in case of
  11461. * context lost for instance.
  11462. */
  11463. rebuild(): void;
  11464. /**
  11465. * Disposes the component and the associated ressources.
  11466. */
  11467. dispose(): void;
  11468. private _pickSpriteButKeepRay;
  11469. private _pointerMove;
  11470. private _pointerDown;
  11471. private _pointerUp;
  11472. }
  11473. }
  11474. declare module BABYLON {
  11475. /** @hidden */
  11476. export var fogFragmentDeclaration: {
  11477. name: string;
  11478. shader: string;
  11479. };
  11480. }
  11481. declare module BABYLON {
  11482. /** @hidden */
  11483. export var fogFragment: {
  11484. name: string;
  11485. shader: string;
  11486. };
  11487. }
  11488. declare module BABYLON {
  11489. /** @hidden */
  11490. export var spritesPixelShader: {
  11491. name: string;
  11492. shader: string;
  11493. };
  11494. }
  11495. declare module BABYLON {
  11496. /** @hidden */
  11497. export var fogVertexDeclaration: {
  11498. name: string;
  11499. shader: string;
  11500. };
  11501. }
  11502. declare module BABYLON {
  11503. /** @hidden */
  11504. export var spritesVertexShader: {
  11505. name: string;
  11506. shader: string;
  11507. };
  11508. }
  11509. declare module BABYLON {
  11510. /**
  11511. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11512. */
  11513. export interface ISpriteManager extends IDisposable {
  11514. /**
  11515. * Restricts the camera to viewing objects with the same layerMask.
  11516. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11517. */
  11518. layerMask: number;
  11519. /**
  11520. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11521. */
  11522. isPickable: boolean;
  11523. /**
  11524. * Specifies the rendering group id for this mesh (0 by default)
  11525. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11526. */
  11527. renderingGroupId: number;
  11528. /**
  11529. * Defines the list of sprites managed by the manager.
  11530. */
  11531. sprites: Array<Sprite>;
  11532. /**
  11533. * Tests the intersection of a sprite with a specific ray.
  11534. * @param ray The ray we are sending to test the collision
  11535. * @param camera The camera space we are sending rays in
  11536. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11537. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11538. * @returns picking info or null.
  11539. */
  11540. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11541. /**
  11542. * Intersects the sprites with a ray
  11543. * @param ray defines the ray to intersect with
  11544. * @param camera defines the current active camera
  11545. * @param predicate defines a predicate used to select candidate sprites
  11546. * @returns null if no hit or a PickingInfo array
  11547. */
  11548. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11549. /**
  11550. * Renders the list of sprites on screen.
  11551. */
  11552. render(): void;
  11553. }
  11554. /**
  11555. * Class used to manage multiple sprites on the same spritesheet
  11556. * @see http://doc.babylonjs.com/babylon101/sprites
  11557. */
  11558. export class SpriteManager implements ISpriteManager {
  11559. /** defines the manager's name */
  11560. name: string;
  11561. /** Gets the list of sprites */
  11562. sprites: Sprite[];
  11563. /** Gets or sets the rendering group id (0 by default) */
  11564. renderingGroupId: number;
  11565. /** Gets or sets camera layer mask */
  11566. layerMask: number;
  11567. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11568. fogEnabled: boolean;
  11569. /** Gets or sets a boolean indicating if the sprites are pickable */
  11570. isPickable: boolean;
  11571. /** Defines the default width of a cell in the spritesheet */
  11572. cellWidth: number;
  11573. /** Defines the default height of a cell in the spritesheet */
  11574. cellHeight: number;
  11575. /** Associative array from JSON sprite data file */
  11576. private _cellData;
  11577. /** Array of sprite names from JSON sprite data file */
  11578. private _spriteMap;
  11579. /** True when packed cell data from JSON file is ready*/
  11580. private _packedAndReady;
  11581. /**
  11582. * An event triggered when the manager is disposed.
  11583. */
  11584. onDisposeObservable: Observable<SpriteManager>;
  11585. private _onDisposeObserver;
  11586. /**
  11587. * Callback called when the manager is disposed
  11588. */
  11589. onDispose: () => void;
  11590. private _capacity;
  11591. private _fromPacked;
  11592. private _spriteTexture;
  11593. private _epsilon;
  11594. private _scene;
  11595. private _vertexData;
  11596. private _buffer;
  11597. private _vertexBuffers;
  11598. private _indexBuffer;
  11599. private _effectBase;
  11600. private _effectFog;
  11601. /**
  11602. * Gets or sets the spritesheet texture
  11603. */
  11604. texture: Texture;
  11605. /**
  11606. * Creates a new sprite manager
  11607. * @param name defines the manager's name
  11608. * @param imgUrl defines the sprite sheet url
  11609. * @param capacity defines the maximum allowed number of sprites
  11610. * @param cellSize defines the size of a sprite cell
  11611. * @param scene defines the hosting scene
  11612. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11613. * @param samplingMode defines the smapling mode to use with spritesheet
  11614. * @param fromPacked set to false; do not alter
  11615. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11616. */
  11617. constructor(
  11618. /** defines the manager's name */
  11619. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11620. private _makePacked;
  11621. private _appendSpriteVertex;
  11622. /**
  11623. * Intersects the sprites with a ray
  11624. * @param ray defines the ray to intersect with
  11625. * @param camera defines the current active camera
  11626. * @param predicate defines a predicate used to select candidate sprites
  11627. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11628. * @returns null if no hit or a PickingInfo
  11629. */
  11630. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11631. /**
  11632. * Intersects the sprites with a ray
  11633. * @param ray defines the ray to intersect with
  11634. * @param camera defines the current active camera
  11635. * @param predicate defines a predicate used to select candidate sprites
  11636. * @returns null if no hit or a PickingInfo array
  11637. */
  11638. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11639. /**
  11640. * Render all child sprites
  11641. */
  11642. render(): void;
  11643. /**
  11644. * Release associated resources
  11645. */
  11646. dispose(): void;
  11647. }
  11648. }
  11649. declare module BABYLON {
  11650. /**
  11651. * Class used to represent a sprite
  11652. * @see http://doc.babylonjs.com/babylon101/sprites
  11653. */
  11654. export class Sprite {
  11655. /** defines the name */
  11656. name: string;
  11657. /** Gets or sets the current world position */
  11658. position: Vector3;
  11659. /** Gets or sets the main color */
  11660. color: Color4;
  11661. /** Gets or sets the width */
  11662. width: number;
  11663. /** Gets or sets the height */
  11664. height: number;
  11665. /** Gets or sets rotation angle */
  11666. angle: number;
  11667. /** Gets or sets the cell index in the sprite sheet */
  11668. cellIndex: number;
  11669. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11670. cellRef: string;
  11671. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11672. invertU: number;
  11673. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11674. invertV: number;
  11675. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11676. disposeWhenFinishedAnimating: boolean;
  11677. /** Gets the list of attached animations */
  11678. animations: Animation[];
  11679. /** Gets or sets a boolean indicating if the sprite can be picked */
  11680. isPickable: boolean;
  11681. /**
  11682. * Gets or sets the associated action manager
  11683. */
  11684. actionManager: Nullable<ActionManager>;
  11685. private _animationStarted;
  11686. private _loopAnimation;
  11687. private _fromIndex;
  11688. private _toIndex;
  11689. private _delay;
  11690. private _direction;
  11691. private _manager;
  11692. private _time;
  11693. private _onAnimationEnd;
  11694. /**
  11695. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11696. */
  11697. isVisible: boolean;
  11698. /**
  11699. * Gets or sets the sprite size
  11700. */
  11701. size: number;
  11702. /**
  11703. * Creates a new Sprite
  11704. * @param name defines the name
  11705. * @param manager defines the manager
  11706. */
  11707. constructor(
  11708. /** defines the name */
  11709. name: string, manager: ISpriteManager);
  11710. /**
  11711. * Starts an animation
  11712. * @param from defines the initial key
  11713. * @param to defines the end key
  11714. * @param loop defines if the animation must loop
  11715. * @param delay defines the start delay (in ms)
  11716. * @param onAnimationEnd defines a callback to call when animation ends
  11717. */
  11718. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11719. /** Stops current animation (if any) */
  11720. stopAnimation(): void;
  11721. /** @hidden */
  11722. _animate(deltaTime: number): void;
  11723. /** Release associated resources */
  11724. dispose(): void;
  11725. }
  11726. }
  11727. declare module BABYLON {
  11728. /**
  11729. * Information about the result of picking within a scene
  11730. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11731. */
  11732. export class PickingInfo {
  11733. /** @hidden */
  11734. _pickingUnavailable: boolean;
  11735. /**
  11736. * If the pick collided with an object
  11737. */
  11738. hit: boolean;
  11739. /**
  11740. * Distance away where the pick collided
  11741. */
  11742. distance: number;
  11743. /**
  11744. * The location of pick collision
  11745. */
  11746. pickedPoint: Nullable<Vector3>;
  11747. /**
  11748. * The mesh corresponding the the pick collision
  11749. */
  11750. pickedMesh: Nullable<AbstractMesh>;
  11751. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11752. bu: number;
  11753. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11754. bv: number;
  11755. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11756. faceId: number;
  11757. /** Id of the the submesh that was picked */
  11758. subMeshId: number;
  11759. /** If a sprite was picked, this will be the sprite the pick collided with */
  11760. pickedSprite: Nullable<Sprite>;
  11761. /**
  11762. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11763. */
  11764. originMesh: Nullable<AbstractMesh>;
  11765. /**
  11766. * The ray that was used to perform the picking.
  11767. */
  11768. ray: Nullable<Ray>;
  11769. /**
  11770. * Gets the normal correspodning to the face the pick collided with
  11771. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11772. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11773. * @returns The normal correspodning to the face the pick collided with
  11774. */
  11775. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11776. /**
  11777. * Gets the texture coordinates of where the pick occured
  11778. * @returns the vector containing the coordnates of the texture
  11779. */
  11780. getTextureCoordinates(): Nullable<Vector2>;
  11781. }
  11782. }
  11783. declare module BABYLON {
  11784. /**
  11785. * Gather the list of pointer event types as constants.
  11786. */
  11787. export class PointerEventTypes {
  11788. /**
  11789. * 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.
  11790. */
  11791. static readonly POINTERDOWN: number;
  11792. /**
  11793. * The pointerup event is fired when a pointer is no longer active.
  11794. */
  11795. static readonly POINTERUP: number;
  11796. /**
  11797. * The pointermove event is fired when a pointer changes coordinates.
  11798. */
  11799. static readonly POINTERMOVE: number;
  11800. /**
  11801. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11802. */
  11803. static readonly POINTERWHEEL: number;
  11804. /**
  11805. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11806. */
  11807. static readonly POINTERPICK: number;
  11808. /**
  11809. * The pointertap event is fired when a the object has been touched and released without drag.
  11810. */
  11811. static readonly POINTERTAP: number;
  11812. /**
  11813. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11814. */
  11815. static readonly POINTERDOUBLETAP: number;
  11816. }
  11817. /**
  11818. * Base class of pointer info types.
  11819. */
  11820. export class PointerInfoBase {
  11821. /**
  11822. * Defines the type of event (PointerEventTypes)
  11823. */
  11824. type: number;
  11825. /**
  11826. * Defines the related dom event
  11827. */
  11828. event: PointerEvent | MouseWheelEvent;
  11829. /**
  11830. * Instantiates the base class of pointers info.
  11831. * @param type Defines the type of event (PointerEventTypes)
  11832. * @param event Defines the related dom event
  11833. */
  11834. constructor(
  11835. /**
  11836. * Defines the type of event (PointerEventTypes)
  11837. */
  11838. type: number,
  11839. /**
  11840. * Defines the related dom event
  11841. */
  11842. event: PointerEvent | MouseWheelEvent);
  11843. }
  11844. /**
  11845. * This class is used to store pointer related info for the onPrePointerObservable event.
  11846. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11847. */
  11848. export class PointerInfoPre extends PointerInfoBase {
  11849. /**
  11850. * Ray from a pointer if availible (eg. 6dof controller)
  11851. */
  11852. ray: Nullable<Ray>;
  11853. /**
  11854. * Defines the local position of the pointer on the canvas.
  11855. */
  11856. localPosition: Vector2;
  11857. /**
  11858. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11859. */
  11860. skipOnPointerObservable: boolean;
  11861. /**
  11862. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11863. * @param type Defines the type of event (PointerEventTypes)
  11864. * @param event Defines the related dom event
  11865. * @param localX Defines the local x coordinates of the pointer when the event occured
  11866. * @param localY Defines the local y coordinates of the pointer when the event occured
  11867. */
  11868. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11869. }
  11870. /**
  11871. * This type contains all the data related to a pointer event in Babylon.js.
  11872. * 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.
  11873. */
  11874. export class PointerInfo extends PointerInfoBase {
  11875. /**
  11876. * Defines the picking info associated to the info (if any)\
  11877. */
  11878. pickInfo: Nullable<PickingInfo>;
  11879. /**
  11880. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11881. * @param type Defines the type of event (PointerEventTypes)
  11882. * @param event Defines the related dom event
  11883. * @param pickInfo Defines the picking info associated to the info (if any)\
  11884. */
  11885. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11886. /**
  11887. * Defines the picking info associated to the info (if any)\
  11888. */
  11889. pickInfo: Nullable<PickingInfo>);
  11890. }
  11891. /**
  11892. * Data relating to a touch event on the screen.
  11893. */
  11894. export interface PointerTouch {
  11895. /**
  11896. * X coordinate of touch.
  11897. */
  11898. x: number;
  11899. /**
  11900. * Y coordinate of touch.
  11901. */
  11902. y: number;
  11903. /**
  11904. * Id of touch. Unique for each finger.
  11905. */
  11906. pointerId: number;
  11907. /**
  11908. * Event type passed from DOM.
  11909. */
  11910. type: any;
  11911. }
  11912. }
  11913. declare module BABYLON {
  11914. /**
  11915. * Manage the mouse inputs to control the movement of a free camera.
  11916. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11917. */
  11918. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11919. /**
  11920. * Define if touch is enabled in the mouse input
  11921. */
  11922. touchEnabled: boolean;
  11923. /**
  11924. * Defines the camera the input is attached to.
  11925. */
  11926. camera: FreeCamera;
  11927. /**
  11928. * Defines the buttons associated with the input to handle camera move.
  11929. */
  11930. buttons: number[];
  11931. /**
  11932. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11933. */
  11934. angularSensibility: number;
  11935. private _pointerInput;
  11936. private _onMouseMove;
  11937. private _observer;
  11938. private previousPosition;
  11939. /**
  11940. * Observable for when a pointer move event occurs containing the move offset
  11941. */
  11942. onPointerMovedObservable: Observable<{
  11943. offsetX: number;
  11944. offsetY: number;
  11945. }>;
  11946. /**
  11947. * @hidden
  11948. * If the camera should be rotated automatically based on pointer movement
  11949. */
  11950. _allowCameraRotation: boolean;
  11951. /**
  11952. * Manage the mouse inputs to control the movement of a free camera.
  11953. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11954. * @param touchEnabled Defines if touch is enabled or not
  11955. */
  11956. constructor(
  11957. /**
  11958. * Define if touch is enabled in the mouse input
  11959. */
  11960. touchEnabled?: boolean);
  11961. /**
  11962. * Attach the input controls to a specific dom element to get the input from.
  11963. * @param element Defines the element the controls should be listened from
  11964. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11965. */
  11966. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11967. /**
  11968. * Called on JS contextmenu event.
  11969. * Override this method to provide functionality.
  11970. */
  11971. protected onContextMenu(evt: PointerEvent): void;
  11972. /**
  11973. * Detach the current controls from the specified dom element.
  11974. * @param element Defines the element to stop listening the inputs from
  11975. */
  11976. detachControl(element: Nullable<HTMLElement>): void;
  11977. /**
  11978. * Gets the class name of the current intput.
  11979. * @returns the class name
  11980. */
  11981. getClassName(): string;
  11982. /**
  11983. * Get the friendly name associated with the input class.
  11984. * @returns the input friendly name
  11985. */
  11986. getSimpleName(): string;
  11987. }
  11988. }
  11989. declare module BABYLON {
  11990. /**
  11991. * Manage the touch inputs to control the movement of a free camera.
  11992. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11993. */
  11994. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11995. /**
  11996. * Defines the camera the input is attached to.
  11997. */
  11998. camera: FreeCamera;
  11999. /**
  12000. * Defines the touch sensibility for rotation.
  12001. * The higher the faster.
  12002. */
  12003. touchAngularSensibility: number;
  12004. /**
  12005. * Defines the touch sensibility for move.
  12006. * The higher the faster.
  12007. */
  12008. touchMoveSensibility: number;
  12009. private _offsetX;
  12010. private _offsetY;
  12011. private _pointerPressed;
  12012. private _pointerInput;
  12013. private _observer;
  12014. private _onLostFocus;
  12015. /**
  12016. * Attach the input controls to a specific dom element to get the input from.
  12017. * @param element Defines the element the controls should be listened from
  12018. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12019. */
  12020. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12021. /**
  12022. * Detach the current controls from the specified dom element.
  12023. * @param element Defines the element to stop listening the inputs from
  12024. */
  12025. detachControl(element: Nullable<HTMLElement>): void;
  12026. /**
  12027. * Update the current camera state depending on the inputs that have been used this frame.
  12028. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12029. */
  12030. checkInputs(): void;
  12031. /**
  12032. * Gets the class name of the current intput.
  12033. * @returns the class name
  12034. */
  12035. getClassName(): string;
  12036. /**
  12037. * Get the friendly name associated with the input class.
  12038. * @returns the input friendly name
  12039. */
  12040. getSimpleName(): string;
  12041. }
  12042. }
  12043. declare module BABYLON {
  12044. /**
  12045. * Default Inputs manager for the FreeCamera.
  12046. * It groups all the default supported inputs for ease of use.
  12047. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12048. */
  12049. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12050. /**
  12051. * @hidden
  12052. */
  12053. _mouseInput: Nullable<FreeCameraMouseInput>;
  12054. /**
  12055. * Instantiates a new FreeCameraInputsManager.
  12056. * @param camera Defines the camera the inputs belong to
  12057. */
  12058. constructor(camera: FreeCamera);
  12059. /**
  12060. * Add keyboard input support to the input manager.
  12061. * @returns the current input manager
  12062. */
  12063. addKeyboard(): FreeCameraInputsManager;
  12064. /**
  12065. * Add mouse input support to the input manager.
  12066. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12067. * @returns the current input manager
  12068. */
  12069. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12070. /**
  12071. * Removes the mouse input support from the manager
  12072. * @returns the current input manager
  12073. */
  12074. removeMouse(): FreeCameraInputsManager;
  12075. /**
  12076. * Add touch input support to the input manager.
  12077. * @returns the current input manager
  12078. */
  12079. addTouch(): FreeCameraInputsManager;
  12080. /**
  12081. * Remove all attached input methods from a camera
  12082. */
  12083. clear(): void;
  12084. }
  12085. }
  12086. declare module BABYLON {
  12087. /**
  12088. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12089. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12090. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12091. */
  12092. export class FreeCamera extends TargetCamera {
  12093. /**
  12094. * Define the collision ellipsoid of the camera.
  12095. * This is helpful to simulate a camera body like the player body around the camera
  12096. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12097. */
  12098. ellipsoid: Vector3;
  12099. /**
  12100. * Define an offset for the position of the ellipsoid around the camera.
  12101. * This can be helpful to determine the center of the body near the gravity center of the body
  12102. * instead of its head.
  12103. */
  12104. ellipsoidOffset: Vector3;
  12105. /**
  12106. * Enable or disable collisions of the camera with the rest of the scene objects.
  12107. */
  12108. checkCollisions: boolean;
  12109. /**
  12110. * Enable or disable gravity on the camera.
  12111. */
  12112. applyGravity: boolean;
  12113. /**
  12114. * Define the input manager associated to the camera.
  12115. */
  12116. inputs: FreeCameraInputsManager;
  12117. /**
  12118. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12119. * Higher values reduce sensitivity.
  12120. */
  12121. /**
  12122. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12123. * Higher values reduce sensitivity.
  12124. */
  12125. angularSensibility: number;
  12126. /**
  12127. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12128. */
  12129. keysUp: number[];
  12130. /**
  12131. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12132. */
  12133. keysDown: number[];
  12134. /**
  12135. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12136. */
  12137. keysLeft: number[];
  12138. /**
  12139. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12140. */
  12141. keysRight: number[];
  12142. /**
  12143. * Event raised when the camera collide with a mesh in the scene.
  12144. */
  12145. onCollide: (collidedMesh: AbstractMesh) => void;
  12146. private _collider;
  12147. private _needMoveForGravity;
  12148. private _oldPosition;
  12149. private _diffPosition;
  12150. private _newPosition;
  12151. /** @hidden */
  12152. _localDirection: Vector3;
  12153. /** @hidden */
  12154. _transformedDirection: Vector3;
  12155. /**
  12156. * Instantiates a Free Camera.
  12157. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12158. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12159. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12160. * @param name Define the name of the camera in the scene
  12161. * @param position Define the start position of the camera in the scene
  12162. * @param scene Define the scene the camera belongs to
  12163. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12164. */
  12165. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12166. /**
  12167. * Attached controls to the current camera.
  12168. * @param element Defines the element the controls should be listened from
  12169. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12170. */
  12171. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12172. /**
  12173. * Detach the current controls from the camera.
  12174. * The camera will stop reacting to inputs.
  12175. * @param element Defines the element to stop listening the inputs from
  12176. */
  12177. detachControl(element: HTMLElement): void;
  12178. private _collisionMask;
  12179. /**
  12180. * Define a collision mask to limit the list of object the camera can collide with
  12181. */
  12182. collisionMask: number;
  12183. /** @hidden */
  12184. _collideWithWorld(displacement: Vector3): void;
  12185. private _onCollisionPositionChange;
  12186. /** @hidden */
  12187. _checkInputs(): void;
  12188. /** @hidden */
  12189. _decideIfNeedsToMove(): boolean;
  12190. /** @hidden */
  12191. _updatePosition(): void;
  12192. /**
  12193. * Destroy the camera and release the current resources hold by it.
  12194. */
  12195. dispose(): void;
  12196. /**
  12197. * Gets the current object class name.
  12198. * @return the class name
  12199. */
  12200. getClassName(): string;
  12201. }
  12202. }
  12203. declare module BABYLON {
  12204. /**
  12205. * Represents a gamepad control stick position
  12206. */
  12207. export class StickValues {
  12208. /**
  12209. * The x component of the control stick
  12210. */
  12211. x: number;
  12212. /**
  12213. * The y component of the control stick
  12214. */
  12215. y: number;
  12216. /**
  12217. * Initializes the gamepad x and y control stick values
  12218. * @param x The x component of the gamepad control stick value
  12219. * @param y The y component of the gamepad control stick value
  12220. */
  12221. constructor(
  12222. /**
  12223. * The x component of the control stick
  12224. */
  12225. x: number,
  12226. /**
  12227. * The y component of the control stick
  12228. */
  12229. y: number);
  12230. }
  12231. /**
  12232. * An interface which manages callbacks for gamepad button changes
  12233. */
  12234. export interface GamepadButtonChanges {
  12235. /**
  12236. * Called when a gamepad has been changed
  12237. */
  12238. changed: boolean;
  12239. /**
  12240. * Called when a gamepad press event has been triggered
  12241. */
  12242. pressChanged: boolean;
  12243. /**
  12244. * Called when a touch event has been triggered
  12245. */
  12246. touchChanged: boolean;
  12247. /**
  12248. * Called when a value has changed
  12249. */
  12250. valueChanged: boolean;
  12251. }
  12252. /**
  12253. * Represents a gamepad
  12254. */
  12255. export class Gamepad {
  12256. /**
  12257. * The id of the gamepad
  12258. */
  12259. id: string;
  12260. /**
  12261. * The index of the gamepad
  12262. */
  12263. index: number;
  12264. /**
  12265. * The browser gamepad
  12266. */
  12267. browserGamepad: any;
  12268. /**
  12269. * Specifies what type of gamepad this represents
  12270. */
  12271. type: number;
  12272. private _leftStick;
  12273. private _rightStick;
  12274. /** @hidden */
  12275. _isConnected: boolean;
  12276. private _leftStickAxisX;
  12277. private _leftStickAxisY;
  12278. private _rightStickAxisX;
  12279. private _rightStickAxisY;
  12280. /**
  12281. * Triggered when the left control stick has been changed
  12282. */
  12283. private _onleftstickchanged;
  12284. /**
  12285. * Triggered when the right control stick has been changed
  12286. */
  12287. private _onrightstickchanged;
  12288. /**
  12289. * Represents a gamepad controller
  12290. */
  12291. static GAMEPAD: number;
  12292. /**
  12293. * Represents a generic controller
  12294. */
  12295. static GENERIC: number;
  12296. /**
  12297. * Represents an XBox controller
  12298. */
  12299. static XBOX: number;
  12300. /**
  12301. * Represents a pose-enabled controller
  12302. */
  12303. static POSE_ENABLED: number;
  12304. /**
  12305. * Represents an Dual Shock controller
  12306. */
  12307. static DUALSHOCK: number;
  12308. /**
  12309. * Specifies whether the left control stick should be Y-inverted
  12310. */
  12311. protected _invertLeftStickY: boolean;
  12312. /**
  12313. * Specifies if the gamepad has been connected
  12314. */
  12315. readonly isConnected: boolean;
  12316. /**
  12317. * Initializes the gamepad
  12318. * @param id The id of the gamepad
  12319. * @param index The index of the gamepad
  12320. * @param browserGamepad The browser gamepad
  12321. * @param leftStickX The x component of the left joystick
  12322. * @param leftStickY The y component of the left joystick
  12323. * @param rightStickX The x component of the right joystick
  12324. * @param rightStickY The y component of the right joystick
  12325. */
  12326. constructor(
  12327. /**
  12328. * The id of the gamepad
  12329. */
  12330. id: string,
  12331. /**
  12332. * The index of the gamepad
  12333. */
  12334. index: number,
  12335. /**
  12336. * The browser gamepad
  12337. */
  12338. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12339. /**
  12340. * Callback triggered when the left joystick has changed
  12341. * @param callback
  12342. */
  12343. onleftstickchanged(callback: (values: StickValues) => void): void;
  12344. /**
  12345. * Callback triggered when the right joystick has changed
  12346. * @param callback
  12347. */
  12348. onrightstickchanged(callback: (values: StickValues) => void): void;
  12349. /**
  12350. * Gets the left joystick
  12351. */
  12352. /**
  12353. * Sets the left joystick values
  12354. */
  12355. leftStick: StickValues;
  12356. /**
  12357. * Gets the right joystick
  12358. */
  12359. /**
  12360. * Sets the right joystick value
  12361. */
  12362. rightStick: StickValues;
  12363. /**
  12364. * Updates the gamepad joystick positions
  12365. */
  12366. update(): void;
  12367. /**
  12368. * Disposes the gamepad
  12369. */
  12370. dispose(): void;
  12371. }
  12372. /**
  12373. * Represents a generic gamepad
  12374. */
  12375. export class GenericPad extends Gamepad {
  12376. private _buttons;
  12377. private _onbuttondown;
  12378. private _onbuttonup;
  12379. /**
  12380. * Observable triggered when a button has been pressed
  12381. */
  12382. onButtonDownObservable: Observable<number>;
  12383. /**
  12384. * Observable triggered when a button has been released
  12385. */
  12386. onButtonUpObservable: Observable<number>;
  12387. /**
  12388. * Callback triggered when a button has been pressed
  12389. * @param callback Called when a button has been pressed
  12390. */
  12391. onbuttondown(callback: (buttonPressed: number) => void): void;
  12392. /**
  12393. * Callback triggered when a button has been released
  12394. * @param callback Called when a button has been released
  12395. */
  12396. onbuttonup(callback: (buttonReleased: number) => void): void;
  12397. /**
  12398. * Initializes the generic gamepad
  12399. * @param id The id of the generic gamepad
  12400. * @param index The index of the generic gamepad
  12401. * @param browserGamepad The browser gamepad
  12402. */
  12403. constructor(id: string, index: number, browserGamepad: any);
  12404. private _setButtonValue;
  12405. /**
  12406. * Updates the generic gamepad
  12407. */
  12408. update(): void;
  12409. /**
  12410. * Disposes the generic gamepad
  12411. */
  12412. dispose(): void;
  12413. }
  12414. }
  12415. declare module BABYLON {
  12416. interface Engine {
  12417. /**
  12418. * Creates a raw texture
  12419. * @param data defines the data to store in the texture
  12420. * @param width defines the width of the texture
  12421. * @param height defines the height of the texture
  12422. * @param format defines the format of the data
  12423. * @param generateMipMaps defines if the engine should generate the mip levels
  12424. * @param invertY defines if data must be stored with Y axis inverted
  12425. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12426. * @param compression defines the compression used (null by default)
  12427. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12428. * @returns the raw texture inside an InternalTexture
  12429. */
  12430. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12431. /**
  12432. * Update a raw texture
  12433. * @param texture defines the texture to update
  12434. * @param data defines the data to store in the texture
  12435. * @param format defines the format of the data
  12436. * @param invertY defines if data must be stored with Y axis inverted
  12437. */
  12438. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12439. /**
  12440. * Update a raw texture
  12441. * @param texture defines the texture to update
  12442. * @param data defines the data to store in the texture
  12443. * @param format defines the format of the data
  12444. * @param invertY defines if data must be stored with Y axis inverted
  12445. * @param compression defines the compression used (null by default)
  12446. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12447. */
  12448. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12449. /**
  12450. * Creates a new raw cube texture
  12451. * @param data defines the array of data to use to create each face
  12452. * @param size defines the size of the textures
  12453. * @param format defines the format of the data
  12454. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12455. * @param generateMipMaps defines if the engine should generate the mip levels
  12456. * @param invertY defines if data must be stored with Y axis inverted
  12457. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12458. * @param compression defines the compression used (null by default)
  12459. * @returns the cube texture as an InternalTexture
  12460. */
  12461. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12462. /**
  12463. * Update a raw cube texture
  12464. * @param texture defines the texture to udpdate
  12465. * @param data defines the data to store
  12466. * @param format defines the data format
  12467. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12468. * @param invertY defines if data must be stored with Y axis inverted
  12469. */
  12470. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12471. /**
  12472. * Update a raw cube texture
  12473. * @param texture defines the texture to udpdate
  12474. * @param data defines the data to store
  12475. * @param format defines the data format
  12476. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12477. * @param invertY defines if data must be stored with Y axis inverted
  12478. * @param compression defines the compression used (null by default)
  12479. */
  12480. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12481. /**
  12482. * Update a raw cube texture
  12483. * @param texture defines the texture to udpdate
  12484. * @param data defines the data to store
  12485. * @param format defines the data format
  12486. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12487. * @param invertY defines if data must be stored with Y axis inverted
  12488. * @param compression defines the compression used (null by default)
  12489. * @param level defines which level of the texture to update
  12490. */
  12491. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12492. /**
  12493. * Creates a new raw cube texture from a specified url
  12494. * @param url defines the url where the data is located
  12495. * @param scene defines the current scene
  12496. * @param size defines the size of the textures
  12497. * @param format defines the format of the data
  12498. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12499. * @param noMipmap defines if the engine should avoid generating the mip levels
  12500. * @param callback defines a callback used to extract texture data from loaded data
  12501. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12502. * @param onLoad defines a callback called when texture is loaded
  12503. * @param onError defines a callback called if there is an error
  12504. * @returns the cube texture as an InternalTexture
  12505. */
  12506. 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;
  12507. /**
  12508. * Creates a new raw cube texture from a specified url
  12509. * @param url defines the url where the data is located
  12510. * @param scene defines the current scene
  12511. * @param size defines the size of the textures
  12512. * @param format defines the format of the data
  12513. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12514. * @param noMipmap defines if the engine should avoid generating the mip levels
  12515. * @param callback defines a callback used to extract texture data from loaded data
  12516. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12517. * @param onLoad defines a callback called when texture is loaded
  12518. * @param onError defines a callback called if there is an error
  12519. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12520. * @param invertY defines if data must be stored with Y axis inverted
  12521. * @returns the cube texture as an InternalTexture
  12522. */
  12523. 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;
  12524. /**
  12525. * Creates a new raw 3D texture
  12526. * @param data defines the data used to create the texture
  12527. * @param width defines the width of the texture
  12528. * @param height defines the height of the texture
  12529. * @param depth defines the depth of the texture
  12530. * @param format defines the format of the texture
  12531. * @param generateMipMaps defines if the engine must generate mip levels
  12532. * @param invertY defines if data must be stored with Y axis inverted
  12533. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12534. * @param compression defines the compressed used (can be null)
  12535. * @param textureType defines the compressed used (can be null)
  12536. * @returns a new raw 3D texture (stored in an InternalTexture)
  12537. */
  12538. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12539. /**
  12540. * Update a raw 3D texture
  12541. * @param texture defines the texture to update
  12542. * @param data defines the data to store
  12543. * @param format defines the data format
  12544. * @param invertY defines if data must be stored with Y axis inverted
  12545. */
  12546. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12547. /**
  12548. * Update a raw 3D texture
  12549. * @param texture defines the texture to update
  12550. * @param data defines the data to store
  12551. * @param format defines the data format
  12552. * @param invertY defines if data must be stored with Y axis inverted
  12553. * @param compression defines the used compression (can be null)
  12554. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12555. */
  12556. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12557. }
  12558. }
  12559. declare module BABYLON {
  12560. /**
  12561. * Raw texture can help creating a texture directly from an array of data.
  12562. * This can be super useful if you either get the data from an uncompressed source or
  12563. * if you wish to create your texture pixel by pixel.
  12564. */
  12565. export class RawTexture extends Texture {
  12566. /**
  12567. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12568. */
  12569. format: number;
  12570. private _engine;
  12571. /**
  12572. * Instantiates a new RawTexture.
  12573. * Raw texture can help creating a texture directly from an array of data.
  12574. * This can be super useful if you either get the data from an uncompressed source or
  12575. * if you wish to create your texture pixel by pixel.
  12576. * @param data define the array of data to use to create the texture
  12577. * @param width define the width of the texture
  12578. * @param height define the height of the texture
  12579. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12580. * @param scene define the scene the texture belongs to
  12581. * @param generateMipMaps define whether mip maps should be generated or not
  12582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12584. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12585. */
  12586. constructor(data: ArrayBufferView, width: number, height: number,
  12587. /**
  12588. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12589. */
  12590. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12591. /**
  12592. * Updates the texture underlying data.
  12593. * @param data Define the new data of the texture
  12594. */
  12595. update(data: ArrayBufferView): void;
  12596. /**
  12597. * Creates a luminance texture from some data.
  12598. * @param data Define the texture data
  12599. * @param width Define the width of the texture
  12600. * @param height Define the height of the texture
  12601. * @param scene Define the scene the texture belongs to
  12602. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12603. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12604. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12605. * @returns the luminance texture
  12606. */
  12607. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12608. /**
  12609. * Creates a luminance alpha texture from some data.
  12610. * @param data Define the texture data
  12611. * @param width Define the width of the texture
  12612. * @param height Define the height of the texture
  12613. * @param scene Define the scene the texture belongs to
  12614. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12615. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12616. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12617. * @returns the luminance alpha texture
  12618. */
  12619. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12620. /**
  12621. * Creates an alpha texture from some data.
  12622. * @param data Define the texture data
  12623. * @param width Define the width of the texture
  12624. * @param height Define the height of the texture
  12625. * @param scene Define the scene the texture belongs to
  12626. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12627. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12628. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12629. * @returns the alpha texture
  12630. */
  12631. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12632. /**
  12633. * Creates a RGB texture from some data.
  12634. * @param data Define the texture data
  12635. * @param width Define the width of the texture
  12636. * @param height Define the height of the texture
  12637. * @param scene Define the scene the texture belongs to
  12638. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12639. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12640. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12641. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12642. * @returns the RGB alpha texture
  12643. */
  12644. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12645. /**
  12646. * Creates a RGBA texture from some data.
  12647. * @param data Define the texture data
  12648. * @param width Define the width of the texture
  12649. * @param height Define the height of the texture
  12650. * @param scene Define the scene the texture belongs to
  12651. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12652. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12653. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12654. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12655. * @returns the RGBA texture
  12656. */
  12657. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12658. /**
  12659. * Creates a R texture from some data.
  12660. * @param data Define the texture data
  12661. * @param width Define the width of the texture
  12662. * @param height Define the height of the texture
  12663. * @param scene Define the scene the texture belongs to
  12664. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12665. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12666. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12667. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12668. * @returns the R texture
  12669. */
  12670. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12671. }
  12672. }
  12673. declare module BABYLON {
  12674. /**
  12675. * Interface for the size containing width and height
  12676. */
  12677. export interface ISize {
  12678. /**
  12679. * Width
  12680. */
  12681. width: number;
  12682. /**
  12683. * Heighht
  12684. */
  12685. height: number;
  12686. }
  12687. /**
  12688. * Size containing widht and height
  12689. */
  12690. export class Size implements ISize {
  12691. /**
  12692. * Width
  12693. */
  12694. width: number;
  12695. /**
  12696. * Height
  12697. */
  12698. height: number;
  12699. /**
  12700. * Creates a Size object from the given width and height (floats).
  12701. * @param width width of the new size
  12702. * @param height height of the new size
  12703. */
  12704. constructor(width: number, height: number);
  12705. /**
  12706. * Returns a string with the Size width and height
  12707. * @returns a string with the Size width and height
  12708. */
  12709. toString(): string;
  12710. /**
  12711. * "Size"
  12712. * @returns the string "Size"
  12713. */
  12714. getClassName(): string;
  12715. /**
  12716. * Returns the Size hash code.
  12717. * @returns a hash code for a unique width and height
  12718. */
  12719. getHashCode(): number;
  12720. /**
  12721. * Updates the current size from the given one.
  12722. * @param src the given size
  12723. */
  12724. copyFrom(src: Size): void;
  12725. /**
  12726. * Updates in place the current Size from the given floats.
  12727. * @param width width of the new size
  12728. * @param height height of the new size
  12729. * @returns the updated Size.
  12730. */
  12731. copyFromFloats(width: number, height: number): Size;
  12732. /**
  12733. * Updates in place the current Size from the given floats.
  12734. * @param width width to set
  12735. * @param height height to set
  12736. * @returns the updated Size.
  12737. */
  12738. set(width: number, height: number): Size;
  12739. /**
  12740. * Multiplies the width and height by numbers
  12741. * @param w factor to multiple the width by
  12742. * @param h factor to multiple the height by
  12743. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12744. */
  12745. multiplyByFloats(w: number, h: number): Size;
  12746. /**
  12747. * Clones the size
  12748. * @returns a new Size copied from the given one.
  12749. */
  12750. clone(): Size;
  12751. /**
  12752. * True if the current Size and the given one width and height are strictly equal.
  12753. * @param other the other size to compare against
  12754. * @returns True if the current Size and the given one width and height are strictly equal.
  12755. */
  12756. equals(other: Size): boolean;
  12757. /**
  12758. * The surface of the Size : width * height (float).
  12759. */
  12760. readonly surface: number;
  12761. /**
  12762. * Create a new size of zero
  12763. * @returns a new Size set to (0.0, 0.0)
  12764. */
  12765. static Zero(): Size;
  12766. /**
  12767. * Sums the width and height of two sizes
  12768. * @param otherSize size to add to this size
  12769. * @returns a new Size set as the addition result of the current Size and the given one.
  12770. */
  12771. add(otherSize: Size): Size;
  12772. /**
  12773. * Subtracts the width and height of two
  12774. * @param otherSize size to subtract to this size
  12775. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12776. */
  12777. subtract(otherSize: Size): Size;
  12778. /**
  12779. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12780. * @param start starting size to lerp between
  12781. * @param end end size to lerp between
  12782. * @param amount amount to lerp between the start and end values
  12783. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12784. */
  12785. static Lerp(start: Size, end: Size, amount: number): Size;
  12786. }
  12787. }
  12788. declare module BABYLON {
  12789. /**
  12790. * Defines a runtime animation
  12791. */
  12792. export class RuntimeAnimation {
  12793. private _events;
  12794. /**
  12795. * The current frame of the runtime animation
  12796. */
  12797. private _currentFrame;
  12798. /**
  12799. * The animation used by the runtime animation
  12800. */
  12801. private _animation;
  12802. /**
  12803. * The target of the runtime animation
  12804. */
  12805. private _target;
  12806. /**
  12807. * The initiating animatable
  12808. */
  12809. private _host;
  12810. /**
  12811. * The original value of the runtime animation
  12812. */
  12813. private _originalValue;
  12814. /**
  12815. * The original blend value of the runtime animation
  12816. */
  12817. private _originalBlendValue;
  12818. /**
  12819. * The offsets cache of the runtime animation
  12820. */
  12821. private _offsetsCache;
  12822. /**
  12823. * The high limits cache of the runtime animation
  12824. */
  12825. private _highLimitsCache;
  12826. /**
  12827. * Specifies if the runtime animation has been stopped
  12828. */
  12829. private _stopped;
  12830. /**
  12831. * The blending factor of the runtime animation
  12832. */
  12833. private _blendingFactor;
  12834. /**
  12835. * The BabylonJS scene
  12836. */
  12837. private _scene;
  12838. /**
  12839. * The current value of the runtime animation
  12840. */
  12841. private _currentValue;
  12842. /** @hidden */
  12843. _animationState: _IAnimationState;
  12844. /**
  12845. * The active target of the runtime animation
  12846. */
  12847. private _activeTargets;
  12848. private _currentActiveTarget;
  12849. private _directTarget;
  12850. /**
  12851. * The target path of the runtime animation
  12852. */
  12853. private _targetPath;
  12854. /**
  12855. * The weight of the runtime animation
  12856. */
  12857. private _weight;
  12858. /**
  12859. * The ratio offset of the runtime animation
  12860. */
  12861. private _ratioOffset;
  12862. /**
  12863. * The previous delay of the runtime animation
  12864. */
  12865. private _previousDelay;
  12866. /**
  12867. * The previous ratio of the runtime animation
  12868. */
  12869. private _previousRatio;
  12870. private _enableBlending;
  12871. private _keys;
  12872. private _minFrame;
  12873. private _maxFrame;
  12874. private _minValue;
  12875. private _maxValue;
  12876. private _targetIsArray;
  12877. /**
  12878. * Gets the current frame of the runtime animation
  12879. */
  12880. readonly currentFrame: number;
  12881. /**
  12882. * Gets the weight of the runtime animation
  12883. */
  12884. readonly weight: number;
  12885. /**
  12886. * Gets the current value of the runtime animation
  12887. */
  12888. readonly currentValue: any;
  12889. /**
  12890. * Gets the target path of the runtime animation
  12891. */
  12892. readonly targetPath: string;
  12893. /**
  12894. * Gets the actual target of the runtime animation
  12895. */
  12896. readonly target: any;
  12897. /** @hidden */
  12898. _onLoop: () => void;
  12899. /**
  12900. * Create a new RuntimeAnimation object
  12901. * @param target defines the target of the animation
  12902. * @param animation defines the source animation object
  12903. * @param scene defines the hosting scene
  12904. * @param host defines the initiating Animatable
  12905. */
  12906. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12907. private _preparePath;
  12908. /**
  12909. * Gets the animation from the runtime animation
  12910. */
  12911. readonly animation: Animation;
  12912. /**
  12913. * Resets the runtime animation to the beginning
  12914. * @param restoreOriginal defines whether to restore the target property to the original value
  12915. */
  12916. reset(restoreOriginal?: boolean): void;
  12917. /**
  12918. * Specifies if the runtime animation is stopped
  12919. * @returns Boolean specifying if the runtime animation is stopped
  12920. */
  12921. isStopped(): boolean;
  12922. /**
  12923. * Disposes of the runtime animation
  12924. */
  12925. dispose(): void;
  12926. /**
  12927. * Apply the interpolated value to the target
  12928. * @param currentValue defines the value computed by the animation
  12929. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12930. */
  12931. setValue(currentValue: any, weight: number): void;
  12932. private _getOriginalValues;
  12933. private _setValue;
  12934. /**
  12935. * Gets the loop pmode of the runtime animation
  12936. * @returns Loop Mode
  12937. */
  12938. private _getCorrectLoopMode;
  12939. /**
  12940. * Move the current animation to a given frame
  12941. * @param frame defines the frame to move to
  12942. */
  12943. goToFrame(frame: number): void;
  12944. /**
  12945. * @hidden Internal use only
  12946. */
  12947. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12948. /**
  12949. * Execute the current animation
  12950. * @param delay defines the delay to add to the current frame
  12951. * @param from defines the lower bound of the animation range
  12952. * @param to defines the upper bound of the animation range
  12953. * @param loop defines if the current animation must loop
  12954. * @param speedRatio defines the current speed ratio
  12955. * @param weight defines the weight of the animation (default is -1 so no weight)
  12956. * @param onLoop optional callback called when animation loops
  12957. * @returns a boolean indicating if the animation is running
  12958. */
  12959. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12960. }
  12961. }
  12962. declare module BABYLON {
  12963. /**
  12964. * Class used to store an actual running animation
  12965. */
  12966. export class Animatable {
  12967. /** defines the target object */
  12968. target: any;
  12969. /** defines the starting frame number (default is 0) */
  12970. fromFrame: number;
  12971. /** defines the ending frame number (default is 100) */
  12972. toFrame: number;
  12973. /** defines if the animation must loop (default is false) */
  12974. loopAnimation: boolean;
  12975. /** defines a callback to call when animation ends if it is not looping */
  12976. onAnimationEnd?: (() => void) | null | undefined;
  12977. /** defines a callback to call when animation loops */
  12978. onAnimationLoop?: (() => void) | null | undefined;
  12979. private _localDelayOffset;
  12980. private _pausedDelay;
  12981. private _runtimeAnimations;
  12982. private _paused;
  12983. private _scene;
  12984. private _speedRatio;
  12985. private _weight;
  12986. private _syncRoot;
  12987. /**
  12988. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12989. * This will only apply for non looping animation (default is true)
  12990. */
  12991. disposeOnEnd: boolean;
  12992. /**
  12993. * Gets a boolean indicating if the animation has started
  12994. */
  12995. animationStarted: boolean;
  12996. /**
  12997. * Observer raised when the animation ends
  12998. */
  12999. onAnimationEndObservable: Observable<Animatable>;
  13000. /**
  13001. * Observer raised when the animation loops
  13002. */
  13003. onAnimationLoopObservable: Observable<Animatable>;
  13004. /**
  13005. * Gets the root Animatable used to synchronize and normalize animations
  13006. */
  13007. readonly syncRoot: Nullable<Animatable>;
  13008. /**
  13009. * Gets the current frame of the first RuntimeAnimation
  13010. * Used to synchronize Animatables
  13011. */
  13012. readonly masterFrame: number;
  13013. /**
  13014. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13015. */
  13016. weight: number;
  13017. /**
  13018. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13019. */
  13020. speedRatio: number;
  13021. /**
  13022. * Creates a new Animatable
  13023. * @param scene defines the hosting scene
  13024. * @param target defines the target object
  13025. * @param fromFrame defines the starting frame number (default is 0)
  13026. * @param toFrame defines the ending frame number (default is 100)
  13027. * @param loopAnimation defines if the animation must loop (default is false)
  13028. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13029. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13030. * @param animations defines a group of animation to add to the new Animatable
  13031. * @param onAnimationLoop defines a callback to call when animation loops
  13032. */
  13033. constructor(scene: Scene,
  13034. /** defines the target object */
  13035. target: any,
  13036. /** defines the starting frame number (default is 0) */
  13037. fromFrame?: number,
  13038. /** defines the ending frame number (default is 100) */
  13039. toFrame?: number,
  13040. /** defines if the animation must loop (default is false) */
  13041. loopAnimation?: boolean, speedRatio?: number,
  13042. /** defines a callback to call when animation ends if it is not looping */
  13043. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13044. /** defines a callback to call when animation loops */
  13045. onAnimationLoop?: (() => void) | null | undefined);
  13046. /**
  13047. * Synchronize and normalize current Animatable with a source Animatable
  13048. * This is useful when using animation weights and when animations are not of the same length
  13049. * @param root defines the root Animatable to synchronize with
  13050. * @returns the current Animatable
  13051. */
  13052. syncWith(root: Animatable): Animatable;
  13053. /**
  13054. * Gets the list of runtime animations
  13055. * @returns an array of RuntimeAnimation
  13056. */
  13057. getAnimations(): RuntimeAnimation[];
  13058. /**
  13059. * Adds more animations to the current animatable
  13060. * @param target defines the target of the animations
  13061. * @param animations defines the new animations to add
  13062. */
  13063. appendAnimations(target: any, animations: Animation[]): void;
  13064. /**
  13065. * Gets the source animation for a specific property
  13066. * @param property defines the propertyu to look for
  13067. * @returns null or the source animation for the given property
  13068. */
  13069. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13070. /**
  13071. * Gets the runtime animation for a specific property
  13072. * @param property defines the propertyu to look for
  13073. * @returns null or the runtime animation for the given property
  13074. */
  13075. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13076. /**
  13077. * Resets the animatable to its original state
  13078. */
  13079. reset(): void;
  13080. /**
  13081. * Allows the animatable to blend with current running animations
  13082. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13083. * @param blendingSpeed defines the blending speed to use
  13084. */
  13085. enableBlending(blendingSpeed: number): void;
  13086. /**
  13087. * Disable animation blending
  13088. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13089. */
  13090. disableBlending(): void;
  13091. /**
  13092. * Jump directly to a given frame
  13093. * @param frame defines the frame to jump to
  13094. */
  13095. goToFrame(frame: number): void;
  13096. /**
  13097. * Pause the animation
  13098. */
  13099. pause(): void;
  13100. /**
  13101. * Restart the animation
  13102. */
  13103. restart(): void;
  13104. private _raiseOnAnimationEnd;
  13105. /**
  13106. * Stop and delete the current animation
  13107. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13108. * @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)
  13109. */
  13110. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13111. /**
  13112. * Wait asynchronously for the animation to end
  13113. * @returns a promise which will be fullfilled when the animation ends
  13114. */
  13115. waitAsync(): Promise<Animatable>;
  13116. /** @hidden */
  13117. _animate(delay: number): boolean;
  13118. }
  13119. interface Scene {
  13120. /** @hidden */
  13121. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13122. /** @hidden */
  13123. _processLateAnimationBindingsForMatrices(holder: {
  13124. totalWeight: number;
  13125. animations: RuntimeAnimation[];
  13126. originalValue: Matrix;
  13127. }): any;
  13128. /** @hidden */
  13129. _processLateAnimationBindingsForQuaternions(holder: {
  13130. totalWeight: number;
  13131. animations: RuntimeAnimation[];
  13132. originalValue: Quaternion;
  13133. }, refQuaternion: Quaternion): Quaternion;
  13134. /** @hidden */
  13135. _processLateAnimationBindings(): void;
  13136. /**
  13137. * Will start the animation sequence of a given target
  13138. * @param target defines the target
  13139. * @param from defines from which frame should animation start
  13140. * @param to defines until which frame should animation run.
  13141. * @param weight defines the weight to apply to the animation (1.0 by default)
  13142. * @param loop defines if the animation loops
  13143. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13144. * @param onAnimationEnd defines the function to be executed when the animation ends
  13145. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13146. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13147. * @param onAnimationLoop defines the callback to call when an animation loops
  13148. * @returns the animatable object created for this animation
  13149. */
  13150. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13151. /**
  13152. * Will start the animation sequence of a given target
  13153. * @param target defines the target
  13154. * @param from defines from which frame should animation start
  13155. * @param to defines until which frame should animation run.
  13156. * @param loop defines if the animation loops
  13157. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13158. * @param onAnimationEnd defines the function to be executed when the animation ends
  13159. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13160. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13161. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13162. * @param onAnimationLoop defines the callback to call when an animation loops
  13163. * @returns the animatable object created for this animation
  13164. */
  13165. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13166. /**
  13167. * Will start the animation sequence of a given target and its hierarchy
  13168. * @param target defines the target
  13169. * @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.
  13170. * @param from defines from which frame should animation start
  13171. * @param to defines until which frame should animation run.
  13172. * @param loop defines if the animation loops
  13173. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13174. * @param onAnimationEnd defines the function to be executed when the animation ends
  13175. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13176. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13177. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13178. * @param onAnimationLoop defines the callback to call when an animation loops
  13179. * @returns the list of created animatables
  13180. */
  13181. 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[];
  13182. /**
  13183. * Begin a new animation on a given node
  13184. * @param target defines the target where the animation will take place
  13185. * @param animations defines the list of animations to start
  13186. * @param from defines the initial value
  13187. * @param to defines the final value
  13188. * @param loop defines if you want animation to loop (off by default)
  13189. * @param speedRatio defines the speed ratio to apply to all animations
  13190. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13191. * @param onAnimationLoop defines the callback to call when an animation loops
  13192. * @returns the list of created animatables
  13193. */
  13194. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13195. /**
  13196. * Begin a new animation on a given node and its hierarchy
  13197. * @param target defines the root node where the animation will take place
  13198. * @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.
  13199. * @param animations defines the list of animations to start
  13200. * @param from defines the initial value
  13201. * @param to defines the final value
  13202. * @param loop defines if you want animation to loop (off by default)
  13203. * @param speedRatio defines the speed ratio to apply to all animations
  13204. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13205. * @param onAnimationLoop defines the callback to call when an animation loops
  13206. * @returns the list of animatables created for all nodes
  13207. */
  13208. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13209. /**
  13210. * Gets the animatable associated with a specific target
  13211. * @param target defines the target of the animatable
  13212. * @returns the required animatable if found
  13213. */
  13214. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13215. /**
  13216. * Gets all animatables associated with a given target
  13217. * @param target defines the target to look animatables for
  13218. * @returns an array of Animatables
  13219. */
  13220. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13221. /**
  13222. * Stops and removes all animations that have been applied to the scene
  13223. */
  13224. stopAllAnimations(): void;
  13225. /**
  13226. * Gets the current delta time used by animation engine
  13227. */
  13228. deltaTime: number;
  13229. }
  13230. interface Bone {
  13231. /**
  13232. * Copy an animation range from another bone
  13233. * @param source defines the source bone
  13234. * @param rangeName defines the range name to copy
  13235. * @param frameOffset defines the frame offset
  13236. * @param rescaleAsRequired defines if rescaling must be applied if required
  13237. * @param skelDimensionsRatio defines the scaling ratio
  13238. * @returns true if operation was successful
  13239. */
  13240. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13241. }
  13242. }
  13243. declare module BABYLON {
  13244. /**
  13245. * Class used to override all child animations of a given target
  13246. */
  13247. export class AnimationPropertiesOverride {
  13248. /**
  13249. * Gets or sets a value indicating if animation blending must be used
  13250. */
  13251. enableBlending: boolean;
  13252. /**
  13253. * Gets or sets the blending speed to use when enableBlending is true
  13254. */
  13255. blendingSpeed: number;
  13256. /**
  13257. * Gets or sets the default loop mode to use
  13258. */
  13259. loopMode: number;
  13260. }
  13261. }
  13262. declare module BABYLON {
  13263. /**
  13264. * Class used to handle skinning animations
  13265. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13266. */
  13267. export class Skeleton implements IAnimatable {
  13268. /** defines the skeleton name */
  13269. name: string;
  13270. /** defines the skeleton Id */
  13271. id: string;
  13272. /**
  13273. * Defines the list of child bones
  13274. */
  13275. bones: Bone[];
  13276. /**
  13277. * Defines an estimate of the dimension of the skeleton at rest
  13278. */
  13279. dimensionsAtRest: Vector3;
  13280. /**
  13281. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13282. */
  13283. needInitialSkinMatrix: boolean;
  13284. /**
  13285. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13286. */
  13287. overrideMesh: Nullable<AbstractMesh>;
  13288. /**
  13289. * Gets the list of animations attached to this skeleton
  13290. */
  13291. animations: Array<Animation>;
  13292. private _scene;
  13293. private _isDirty;
  13294. private _transformMatrices;
  13295. private _transformMatrixTexture;
  13296. private _meshesWithPoseMatrix;
  13297. private _animatables;
  13298. private _identity;
  13299. private _synchronizedWithMesh;
  13300. private _ranges;
  13301. private _lastAbsoluteTransformsUpdateId;
  13302. private _canUseTextureForBones;
  13303. private _uniqueId;
  13304. /** @hidden */
  13305. _numBonesWithLinkedTransformNode: number;
  13306. /** @hidden */
  13307. _hasWaitingData: Nullable<boolean>;
  13308. /**
  13309. * Specifies if the skeleton should be serialized
  13310. */
  13311. doNotSerialize: boolean;
  13312. private _useTextureToStoreBoneMatrices;
  13313. /**
  13314. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13315. * Please note that this option is not available if the hardware does not support it
  13316. */
  13317. useTextureToStoreBoneMatrices: boolean;
  13318. private _animationPropertiesOverride;
  13319. /**
  13320. * Gets or sets the animation properties override
  13321. */
  13322. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13323. /**
  13324. * List of inspectable custom properties (used by the Inspector)
  13325. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13326. */
  13327. inspectableCustomProperties: IInspectable[];
  13328. /**
  13329. * An observable triggered before computing the skeleton's matrices
  13330. */
  13331. onBeforeComputeObservable: Observable<Skeleton>;
  13332. /**
  13333. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13334. */
  13335. readonly isUsingTextureForMatrices: boolean;
  13336. /**
  13337. * Gets the unique ID of this skeleton
  13338. */
  13339. readonly uniqueId: number;
  13340. /**
  13341. * Creates a new skeleton
  13342. * @param name defines the skeleton name
  13343. * @param id defines the skeleton Id
  13344. * @param scene defines the hosting scene
  13345. */
  13346. constructor(
  13347. /** defines the skeleton name */
  13348. name: string,
  13349. /** defines the skeleton Id */
  13350. id: string, scene: Scene);
  13351. /**
  13352. * Gets the current object class name.
  13353. * @return the class name
  13354. */
  13355. getClassName(): string;
  13356. /**
  13357. * Returns an array containing the root bones
  13358. * @returns an array containing the root bones
  13359. */
  13360. getChildren(): Array<Bone>;
  13361. /**
  13362. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13363. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13364. * @returns a Float32Array containing matrices data
  13365. */
  13366. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13367. /**
  13368. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13369. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13370. * @returns a raw texture containing the data
  13371. */
  13372. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13373. /**
  13374. * Gets the current hosting scene
  13375. * @returns a scene object
  13376. */
  13377. getScene(): Scene;
  13378. /**
  13379. * Gets a string representing the current skeleton data
  13380. * @param fullDetails defines a boolean indicating if we want a verbose version
  13381. * @returns a string representing the current skeleton data
  13382. */
  13383. toString(fullDetails?: boolean): string;
  13384. /**
  13385. * Get bone's index searching by name
  13386. * @param name defines bone's name to search for
  13387. * @return the indice of the bone. Returns -1 if not found
  13388. */
  13389. getBoneIndexByName(name: string): number;
  13390. /**
  13391. * Creater a new animation range
  13392. * @param name defines the name of the range
  13393. * @param from defines the start key
  13394. * @param to defines the end key
  13395. */
  13396. createAnimationRange(name: string, from: number, to: number): void;
  13397. /**
  13398. * Delete a specific animation range
  13399. * @param name defines the name of the range
  13400. * @param deleteFrames defines if frames must be removed as well
  13401. */
  13402. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13403. /**
  13404. * Gets a specific animation range
  13405. * @param name defines the name of the range to look for
  13406. * @returns the requested animation range or null if not found
  13407. */
  13408. getAnimationRange(name: string): Nullable<AnimationRange>;
  13409. /**
  13410. * Gets the list of all animation ranges defined on this skeleton
  13411. * @returns an array
  13412. */
  13413. getAnimationRanges(): Nullable<AnimationRange>[];
  13414. /**
  13415. * Copy animation range from a source skeleton.
  13416. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13417. * @param source defines the source skeleton
  13418. * @param name defines the name of the range to copy
  13419. * @param rescaleAsRequired defines if rescaling must be applied if required
  13420. * @returns true if operation was successful
  13421. */
  13422. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13423. /**
  13424. * Forces the skeleton to go to rest pose
  13425. */
  13426. returnToRest(): void;
  13427. private _getHighestAnimationFrame;
  13428. /**
  13429. * Begin a specific animation range
  13430. * @param name defines the name of the range to start
  13431. * @param loop defines if looping must be turned on (false by default)
  13432. * @param speedRatio defines the speed ratio to apply (1 by default)
  13433. * @param onAnimationEnd defines a callback which will be called when animation will end
  13434. * @returns a new animatable
  13435. */
  13436. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13437. /** @hidden */
  13438. _markAsDirty(): void;
  13439. /** @hidden */
  13440. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13441. /** @hidden */
  13442. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13443. private _computeTransformMatrices;
  13444. /**
  13445. * Build all resources required to render a skeleton
  13446. */
  13447. prepare(): void;
  13448. /**
  13449. * Gets the list of animatables currently running for this skeleton
  13450. * @returns an array of animatables
  13451. */
  13452. getAnimatables(): IAnimatable[];
  13453. /**
  13454. * Clone the current skeleton
  13455. * @param name defines the name of the new skeleton
  13456. * @param id defines the id of the new skeleton
  13457. * @returns the new skeleton
  13458. */
  13459. clone(name: string, id: string): Skeleton;
  13460. /**
  13461. * Enable animation blending for this skeleton
  13462. * @param blendingSpeed defines the blending speed to apply
  13463. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13464. */
  13465. enableBlending(blendingSpeed?: number): void;
  13466. /**
  13467. * Releases all resources associated with the current skeleton
  13468. */
  13469. dispose(): void;
  13470. /**
  13471. * Serialize the skeleton in a JSON object
  13472. * @returns a JSON object
  13473. */
  13474. serialize(): any;
  13475. /**
  13476. * Creates a new skeleton from serialized data
  13477. * @param parsedSkeleton defines the serialized data
  13478. * @param scene defines the hosting scene
  13479. * @returns a new skeleton
  13480. */
  13481. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13482. /**
  13483. * Compute all node absolute transforms
  13484. * @param forceUpdate defines if computation must be done even if cache is up to date
  13485. */
  13486. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13487. /**
  13488. * Gets the root pose matrix
  13489. * @returns a matrix
  13490. */
  13491. getPoseMatrix(): Nullable<Matrix>;
  13492. /**
  13493. * Sorts bones per internal index
  13494. */
  13495. sortBones(): void;
  13496. private _sortBones;
  13497. }
  13498. }
  13499. declare module BABYLON {
  13500. /**
  13501. * Class used to store bone information
  13502. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13503. */
  13504. export class Bone extends Node {
  13505. /**
  13506. * defines the bone name
  13507. */
  13508. name: string;
  13509. private static _tmpVecs;
  13510. private static _tmpQuat;
  13511. private static _tmpMats;
  13512. /**
  13513. * Gets the list of child bones
  13514. */
  13515. children: Bone[];
  13516. /** Gets the animations associated with this bone */
  13517. animations: Animation[];
  13518. /**
  13519. * Gets or sets bone length
  13520. */
  13521. length: number;
  13522. /**
  13523. * @hidden Internal only
  13524. * Set this value to map this bone to a different index in the transform matrices
  13525. * Set this value to -1 to exclude the bone from the transform matrices
  13526. */
  13527. _index: Nullable<number>;
  13528. private _skeleton;
  13529. private _localMatrix;
  13530. private _restPose;
  13531. private _baseMatrix;
  13532. private _absoluteTransform;
  13533. private _invertedAbsoluteTransform;
  13534. private _parent;
  13535. private _scalingDeterminant;
  13536. private _worldTransform;
  13537. private _localScaling;
  13538. private _localRotation;
  13539. private _localPosition;
  13540. private _needToDecompose;
  13541. private _needToCompose;
  13542. /** @hidden */
  13543. _linkedTransformNode: Nullable<TransformNode>;
  13544. /** @hidden */
  13545. _waitingTransformNodeId: Nullable<string>;
  13546. /** @hidden */
  13547. /** @hidden */
  13548. _matrix: Matrix;
  13549. /**
  13550. * Create a new bone
  13551. * @param name defines the bone name
  13552. * @param skeleton defines the parent skeleton
  13553. * @param parentBone defines the parent (can be null if the bone is the root)
  13554. * @param localMatrix defines the local matrix
  13555. * @param restPose defines the rest pose matrix
  13556. * @param baseMatrix defines the base matrix
  13557. * @param index defines index of the bone in the hiearchy
  13558. */
  13559. constructor(
  13560. /**
  13561. * defines the bone name
  13562. */
  13563. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13564. /**
  13565. * Gets the current object class name.
  13566. * @return the class name
  13567. */
  13568. getClassName(): string;
  13569. /**
  13570. * Gets the parent skeleton
  13571. * @returns a skeleton
  13572. */
  13573. getSkeleton(): Skeleton;
  13574. /**
  13575. * Gets parent bone
  13576. * @returns a bone or null if the bone is the root of the bone hierarchy
  13577. */
  13578. getParent(): Nullable<Bone>;
  13579. /**
  13580. * Returns an array containing the root bones
  13581. * @returns an array containing the root bones
  13582. */
  13583. getChildren(): Array<Bone>;
  13584. /**
  13585. * Sets the parent bone
  13586. * @param parent defines the parent (can be null if the bone is the root)
  13587. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13588. */
  13589. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13590. /**
  13591. * Gets the local matrix
  13592. * @returns a matrix
  13593. */
  13594. getLocalMatrix(): Matrix;
  13595. /**
  13596. * Gets the base matrix (initial matrix which remains unchanged)
  13597. * @returns a matrix
  13598. */
  13599. getBaseMatrix(): Matrix;
  13600. /**
  13601. * Gets the rest pose matrix
  13602. * @returns a matrix
  13603. */
  13604. getRestPose(): Matrix;
  13605. /**
  13606. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13607. */
  13608. getWorldMatrix(): Matrix;
  13609. /**
  13610. * Sets the local matrix to rest pose matrix
  13611. */
  13612. returnToRest(): void;
  13613. /**
  13614. * Gets the inverse of the absolute transform matrix.
  13615. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13616. * @returns a matrix
  13617. */
  13618. getInvertedAbsoluteTransform(): Matrix;
  13619. /**
  13620. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13621. * @returns a matrix
  13622. */
  13623. getAbsoluteTransform(): Matrix;
  13624. /**
  13625. * Links with the given transform node.
  13626. * The local matrix of this bone is copied from the transform node every frame.
  13627. * @param transformNode defines the transform node to link to
  13628. */
  13629. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13630. /**
  13631. * Gets the node used to drive the bone's transformation
  13632. * @returns a transform node or null
  13633. */
  13634. getTransformNode(): Nullable<TransformNode>;
  13635. /** Gets or sets current position (in local space) */
  13636. position: Vector3;
  13637. /** Gets or sets current rotation (in local space) */
  13638. rotation: Vector3;
  13639. /** Gets or sets current rotation quaternion (in local space) */
  13640. rotationQuaternion: Quaternion;
  13641. /** Gets or sets current scaling (in local space) */
  13642. scaling: Vector3;
  13643. /**
  13644. * Gets the animation properties override
  13645. */
  13646. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13647. private _decompose;
  13648. private _compose;
  13649. /**
  13650. * Update the base and local matrices
  13651. * @param matrix defines the new base or local matrix
  13652. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13653. * @param updateLocalMatrix defines if the local matrix should be updated
  13654. */
  13655. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13656. /** @hidden */
  13657. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13658. /**
  13659. * Flag the bone as dirty (Forcing it to update everything)
  13660. */
  13661. markAsDirty(): void;
  13662. /** @hidden */
  13663. _markAsDirtyAndCompose(): void;
  13664. private _markAsDirtyAndDecompose;
  13665. /**
  13666. * Translate the bone in local or world space
  13667. * @param vec The amount to translate the bone
  13668. * @param space The space that the translation is in
  13669. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13670. */
  13671. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13672. /**
  13673. * Set the postion of the bone in local or world space
  13674. * @param position The position to set the bone
  13675. * @param space The space that the position is in
  13676. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13677. */
  13678. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13679. /**
  13680. * Set the absolute position of the bone (world space)
  13681. * @param position The position to set the bone
  13682. * @param mesh The mesh that this bone is attached to
  13683. */
  13684. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13685. /**
  13686. * Scale the bone on the x, y and z axes (in local space)
  13687. * @param x The amount to scale the bone on the x axis
  13688. * @param y The amount to scale the bone on the y axis
  13689. * @param z The amount to scale the bone on the z axis
  13690. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13691. */
  13692. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13693. /**
  13694. * Set the bone scaling in local space
  13695. * @param scale defines the scaling vector
  13696. */
  13697. setScale(scale: Vector3): void;
  13698. /**
  13699. * Gets the current scaling in local space
  13700. * @returns the current scaling vector
  13701. */
  13702. getScale(): Vector3;
  13703. /**
  13704. * Gets the current scaling in local space and stores it in a target vector
  13705. * @param result defines the target vector
  13706. */
  13707. getScaleToRef(result: Vector3): void;
  13708. /**
  13709. * Set the yaw, pitch, and roll of the bone in local or world space
  13710. * @param yaw The rotation of the bone on the y axis
  13711. * @param pitch The rotation of the bone on the x axis
  13712. * @param roll The rotation of the bone on the z axis
  13713. * @param space The space that the axes of rotation are in
  13714. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13715. */
  13716. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13717. /**
  13718. * Add a rotation to the bone on an axis in local or world space
  13719. * @param axis The axis to rotate the bone on
  13720. * @param amount The amount to rotate the bone
  13721. * @param space The space that the axis is in
  13722. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13723. */
  13724. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13725. /**
  13726. * Set the rotation of the bone to a particular axis angle in local or world space
  13727. * @param axis The axis to rotate the bone on
  13728. * @param angle The angle that the bone should be rotated to
  13729. * @param space The space that the axis is in
  13730. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13731. */
  13732. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13733. /**
  13734. * Set the euler rotation of the bone in local of world space
  13735. * @param rotation The euler rotation that the bone should be set to
  13736. * @param space The space that the rotation is in
  13737. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13738. */
  13739. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13740. /**
  13741. * Set the quaternion rotation of the bone in local of world space
  13742. * @param quat The quaternion rotation that the bone should be set to
  13743. * @param space The space that the rotation is in
  13744. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13745. */
  13746. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13747. /**
  13748. * Set the rotation matrix of the bone in local of world space
  13749. * @param rotMat The rotation matrix that the bone should be set to
  13750. * @param space The space that the rotation is in
  13751. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13752. */
  13753. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13754. private _rotateWithMatrix;
  13755. private _getNegativeRotationToRef;
  13756. /**
  13757. * Get the position of the bone in local or world space
  13758. * @param space The space that the returned position is in
  13759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13760. * @returns The position of the bone
  13761. */
  13762. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13763. /**
  13764. * Copy the position of the bone to a vector3 in local or world space
  13765. * @param space The space that the returned position is in
  13766. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13767. * @param result The vector3 to copy the position to
  13768. */
  13769. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13770. /**
  13771. * Get the absolute position of the bone (world space)
  13772. * @param mesh The mesh that this bone is attached to
  13773. * @returns The absolute position of the bone
  13774. */
  13775. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13776. /**
  13777. * Copy the absolute position of the bone (world space) to the result param
  13778. * @param mesh The mesh that this bone is attached to
  13779. * @param result The vector3 to copy the absolute position to
  13780. */
  13781. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13782. /**
  13783. * Compute the absolute transforms of this bone and its children
  13784. */
  13785. computeAbsoluteTransforms(): void;
  13786. /**
  13787. * Get the world direction from an axis that is in the local space of the bone
  13788. * @param localAxis The local direction that is used to compute the world direction
  13789. * @param mesh The mesh that this bone is attached to
  13790. * @returns The world direction
  13791. */
  13792. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13793. /**
  13794. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13795. * @param localAxis The local direction that is used to compute the world direction
  13796. * @param mesh The mesh that this bone is attached to
  13797. * @param result The vector3 that the world direction will be copied to
  13798. */
  13799. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13800. /**
  13801. * Get the euler rotation of the bone in local or world space
  13802. * @param space The space that the rotation should be in
  13803. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13804. * @returns The euler rotation
  13805. */
  13806. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13807. /**
  13808. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13809. * @param space The space that the rotation should be in
  13810. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13811. * @param result The vector3 that the rotation should be copied to
  13812. */
  13813. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13814. /**
  13815. * Get the quaternion rotation of the bone in either local or world space
  13816. * @param space The space that the rotation should be in
  13817. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13818. * @returns The quaternion rotation
  13819. */
  13820. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13821. /**
  13822. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13823. * @param space The space that the rotation should be in
  13824. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13825. * @param result The quaternion that the rotation should be copied to
  13826. */
  13827. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13828. /**
  13829. * Get the rotation matrix of the bone in local or world space
  13830. * @param space The space that the rotation should be in
  13831. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13832. * @returns The rotation matrix
  13833. */
  13834. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13835. /**
  13836. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13837. * @param space The space that the rotation should be in
  13838. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13839. * @param result The quaternion that the rotation should be copied to
  13840. */
  13841. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13842. /**
  13843. * Get the world position of a point that is in the local space of the bone
  13844. * @param position The local position
  13845. * @param mesh The mesh that this bone is attached to
  13846. * @returns The world position
  13847. */
  13848. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13849. /**
  13850. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13851. * @param position The local position
  13852. * @param mesh The mesh that this bone is attached to
  13853. * @param result The vector3 that the world position should be copied to
  13854. */
  13855. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13856. /**
  13857. * Get the local position of a point that is in world space
  13858. * @param position The world position
  13859. * @param mesh The mesh that this bone is attached to
  13860. * @returns The local position
  13861. */
  13862. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13863. /**
  13864. * Get the local position of a point that is in world space and copy it to the result param
  13865. * @param position The world position
  13866. * @param mesh The mesh that this bone is attached to
  13867. * @param result The vector3 that the local position should be copied to
  13868. */
  13869. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13870. }
  13871. }
  13872. declare module BABYLON {
  13873. /**
  13874. * 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.
  13875. * @see https://doc.babylonjs.com/how_to/transformnode
  13876. */
  13877. export class TransformNode extends Node {
  13878. /**
  13879. * Object will not rotate to face the camera
  13880. */
  13881. static BILLBOARDMODE_NONE: number;
  13882. /**
  13883. * Object will rotate to face the camera but only on the x axis
  13884. */
  13885. static BILLBOARDMODE_X: number;
  13886. /**
  13887. * Object will rotate to face the camera but only on the y axis
  13888. */
  13889. static BILLBOARDMODE_Y: number;
  13890. /**
  13891. * Object will rotate to face the camera but only on the z axis
  13892. */
  13893. static BILLBOARDMODE_Z: number;
  13894. /**
  13895. * Object will rotate to face the camera
  13896. */
  13897. static BILLBOARDMODE_ALL: number;
  13898. /**
  13899. * Object will rotate to face the camera's position instead of orientation
  13900. */
  13901. static BILLBOARDMODE_USE_POSITION: number;
  13902. private _forward;
  13903. private _forwardInverted;
  13904. private _up;
  13905. private _right;
  13906. private _rightInverted;
  13907. private _position;
  13908. private _rotation;
  13909. private _rotationQuaternion;
  13910. protected _scaling: Vector3;
  13911. protected _isDirty: boolean;
  13912. private _transformToBoneReferal;
  13913. private _isAbsoluteSynced;
  13914. private _billboardMode;
  13915. /**
  13916. * Gets or sets the billboard mode. Default is 0.
  13917. *
  13918. * | Value | Type | Description |
  13919. * | --- | --- | --- |
  13920. * | 0 | BILLBOARDMODE_NONE | |
  13921. * | 1 | BILLBOARDMODE_X | |
  13922. * | 2 | BILLBOARDMODE_Y | |
  13923. * | 4 | BILLBOARDMODE_Z | |
  13924. * | 7 | BILLBOARDMODE_ALL | |
  13925. *
  13926. */
  13927. billboardMode: number;
  13928. private _preserveParentRotationForBillboard;
  13929. /**
  13930. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13931. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13932. */
  13933. preserveParentRotationForBillboard: boolean;
  13934. /**
  13935. * 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
  13936. */
  13937. scalingDeterminant: number;
  13938. private _infiniteDistance;
  13939. /**
  13940. * Gets or sets the distance of the object to max, often used by skybox
  13941. */
  13942. infiniteDistance: boolean;
  13943. /**
  13944. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13945. * By default the system will update normals to compensate
  13946. */
  13947. ignoreNonUniformScaling: boolean;
  13948. /**
  13949. * 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
  13950. */
  13951. reIntegrateRotationIntoRotationQuaternion: boolean;
  13952. /** @hidden */
  13953. _poseMatrix: Nullable<Matrix>;
  13954. /** @hidden */
  13955. _localMatrix: Matrix;
  13956. private _usePivotMatrix;
  13957. private _absolutePosition;
  13958. private _absoluteScaling;
  13959. private _absoluteRotationQuaternion;
  13960. private _pivotMatrix;
  13961. private _pivotMatrixInverse;
  13962. protected _postMultiplyPivotMatrix: boolean;
  13963. protected _isWorldMatrixFrozen: boolean;
  13964. /** @hidden */
  13965. _indexInSceneTransformNodesArray: number;
  13966. /**
  13967. * An event triggered after the world matrix is updated
  13968. */
  13969. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13970. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13971. /**
  13972. * Gets a string identifying the name of the class
  13973. * @returns "TransformNode" string
  13974. */
  13975. getClassName(): string;
  13976. /**
  13977. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13978. */
  13979. position: Vector3;
  13980. /**
  13981. * 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)).
  13982. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13983. */
  13984. rotation: Vector3;
  13985. /**
  13986. * 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)).
  13987. */
  13988. scaling: Vector3;
  13989. /**
  13990. * 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).
  13991. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13992. */
  13993. rotationQuaternion: Nullable<Quaternion>;
  13994. /**
  13995. * The forward direction of that transform in world space.
  13996. */
  13997. readonly forward: Vector3;
  13998. /**
  13999. * The up direction of that transform in world space.
  14000. */
  14001. readonly up: Vector3;
  14002. /**
  14003. * The right direction of that transform in world space.
  14004. */
  14005. readonly right: Vector3;
  14006. /**
  14007. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14008. * @param matrix the matrix to copy the pose from
  14009. * @returns this TransformNode.
  14010. */
  14011. updatePoseMatrix(matrix: Matrix): TransformNode;
  14012. /**
  14013. * Returns the mesh Pose matrix.
  14014. * @returns the pose matrix
  14015. */
  14016. getPoseMatrix(): Matrix;
  14017. /** @hidden */
  14018. _isSynchronized(): boolean;
  14019. /** @hidden */
  14020. _initCache(): void;
  14021. /**
  14022. * Flag the transform node as dirty (Forcing it to update everything)
  14023. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14024. * @returns this transform node
  14025. */
  14026. markAsDirty(property: string): TransformNode;
  14027. /**
  14028. * Returns the current mesh absolute position.
  14029. * Returns a Vector3.
  14030. */
  14031. readonly absolutePosition: Vector3;
  14032. /**
  14033. * Returns the current mesh absolute scaling.
  14034. * Returns a Vector3.
  14035. */
  14036. readonly absoluteScaling: Vector3;
  14037. /**
  14038. * Returns the current mesh absolute rotation.
  14039. * Returns a Quaternion.
  14040. */
  14041. readonly absoluteRotationQuaternion: Quaternion;
  14042. /**
  14043. * Sets a new matrix to apply before all other transformation
  14044. * @param matrix defines the transform matrix
  14045. * @returns the current TransformNode
  14046. */
  14047. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14048. /**
  14049. * Sets a new pivot matrix to the current node
  14050. * @param matrix defines the new pivot matrix to use
  14051. * @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
  14052. * @returns the current TransformNode
  14053. */
  14054. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14055. /**
  14056. * Returns the mesh pivot matrix.
  14057. * Default : Identity.
  14058. * @returns the matrix
  14059. */
  14060. getPivotMatrix(): Matrix;
  14061. /**
  14062. * Instantiate (when possible) or clone that node with its hierarchy
  14063. * @param newParent defines the new parent to use for the instance (or clone)
  14064. * @returns an instance (or a clone) of the current node with its hiearchy
  14065. */
  14066. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14067. /**
  14068. * Prevents the World matrix to be computed any longer
  14069. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14070. * @returns the TransformNode.
  14071. */
  14072. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14073. /**
  14074. * Allows back the World matrix computation.
  14075. * @returns the TransformNode.
  14076. */
  14077. unfreezeWorldMatrix(): this;
  14078. /**
  14079. * True if the World matrix has been frozen.
  14080. */
  14081. readonly isWorldMatrixFrozen: boolean;
  14082. /**
  14083. * Retuns the mesh absolute position in the World.
  14084. * @returns a Vector3.
  14085. */
  14086. getAbsolutePosition(): Vector3;
  14087. /**
  14088. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14089. * @param absolutePosition the absolute position to set
  14090. * @returns the TransformNode.
  14091. */
  14092. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14093. /**
  14094. * Sets the mesh position in its local space.
  14095. * @param vector3 the position to set in localspace
  14096. * @returns the TransformNode.
  14097. */
  14098. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14099. /**
  14100. * Returns the mesh position in the local space from the current World matrix values.
  14101. * @returns a new Vector3.
  14102. */
  14103. getPositionExpressedInLocalSpace(): Vector3;
  14104. /**
  14105. * Translates the mesh along the passed Vector3 in its local space.
  14106. * @param vector3 the distance to translate in localspace
  14107. * @returns the TransformNode.
  14108. */
  14109. locallyTranslate(vector3: Vector3): TransformNode;
  14110. private static _lookAtVectorCache;
  14111. /**
  14112. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14113. * @param targetPoint the position (must be in same space as current mesh) to look at
  14114. * @param yawCor optional yaw (y-axis) correction in radians
  14115. * @param pitchCor optional pitch (x-axis) correction in radians
  14116. * @param rollCor optional roll (z-axis) correction in radians
  14117. * @param space the choosen space of the target
  14118. * @returns the TransformNode.
  14119. */
  14120. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14121. /**
  14122. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14123. * This Vector3 is expressed in the World space.
  14124. * @param localAxis axis to rotate
  14125. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14126. */
  14127. getDirection(localAxis: Vector3): Vector3;
  14128. /**
  14129. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14130. * localAxis is expressed in the mesh local space.
  14131. * result is computed in the Wordl space from the mesh World matrix.
  14132. * @param localAxis axis to rotate
  14133. * @param result the resulting transformnode
  14134. * @returns this TransformNode.
  14135. */
  14136. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14137. /**
  14138. * Sets this transform node rotation to the given local axis.
  14139. * @param localAxis the axis in local space
  14140. * @param yawCor optional yaw (y-axis) correction in radians
  14141. * @param pitchCor optional pitch (x-axis) correction in radians
  14142. * @param rollCor optional roll (z-axis) correction in radians
  14143. * @returns this TransformNode
  14144. */
  14145. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14146. /**
  14147. * Sets a new pivot point to the current node
  14148. * @param point defines the new pivot point to use
  14149. * @param space defines if the point is in world or local space (local by default)
  14150. * @returns the current TransformNode
  14151. */
  14152. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14153. /**
  14154. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14155. * @returns the pivot point
  14156. */
  14157. getPivotPoint(): Vector3;
  14158. /**
  14159. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14160. * @param result the vector3 to store the result
  14161. * @returns this TransformNode.
  14162. */
  14163. getPivotPointToRef(result: Vector3): TransformNode;
  14164. /**
  14165. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14166. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14167. */
  14168. getAbsolutePivotPoint(): Vector3;
  14169. /**
  14170. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14171. * @param result vector3 to store the result
  14172. * @returns this TransformNode.
  14173. */
  14174. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14175. /**
  14176. * Defines the passed node as the parent of the current node.
  14177. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14178. * @see https://doc.babylonjs.com/how_to/parenting
  14179. * @param node the node ot set as the parent
  14180. * @returns this TransformNode.
  14181. */
  14182. setParent(node: Nullable<Node>): TransformNode;
  14183. private _nonUniformScaling;
  14184. /**
  14185. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14186. */
  14187. readonly nonUniformScaling: boolean;
  14188. /** @hidden */
  14189. _updateNonUniformScalingState(value: boolean): boolean;
  14190. /**
  14191. * Attach the current TransformNode to another TransformNode associated with a bone
  14192. * @param bone Bone affecting the TransformNode
  14193. * @param affectedTransformNode TransformNode associated with the bone
  14194. * @returns this object
  14195. */
  14196. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14197. /**
  14198. * Detach the transform node if its associated with a bone
  14199. * @returns this object
  14200. */
  14201. detachFromBone(): TransformNode;
  14202. private static _rotationAxisCache;
  14203. /**
  14204. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14205. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14206. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14207. * The passed axis is also normalized.
  14208. * @param axis the axis to rotate around
  14209. * @param amount the amount to rotate in radians
  14210. * @param space Space to rotate in (Default: local)
  14211. * @returns the TransformNode.
  14212. */
  14213. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14214. /**
  14215. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14216. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14217. * The passed axis is also normalized. .
  14218. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14219. * @param point the point to rotate around
  14220. * @param axis the axis to rotate around
  14221. * @param amount the amount to rotate in radians
  14222. * @returns the TransformNode
  14223. */
  14224. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14225. /**
  14226. * Translates the mesh along the axis vector for the passed distance in the given space.
  14227. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14228. * @param axis the axis to translate in
  14229. * @param distance the distance to translate
  14230. * @param space Space to rotate in (Default: local)
  14231. * @returns the TransformNode.
  14232. */
  14233. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14234. /**
  14235. * Adds a rotation step to the mesh current rotation.
  14236. * x, y, z are Euler angles expressed in radians.
  14237. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14238. * This means this rotation is made in the mesh local space only.
  14239. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14240. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14241. * ```javascript
  14242. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14243. * ```
  14244. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14245. * 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.
  14246. * @param x Rotation to add
  14247. * @param y Rotation to add
  14248. * @param z Rotation to add
  14249. * @returns the TransformNode.
  14250. */
  14251. addRotation(x: number, y: number, z: number): TransformNode;
  14252. /**
  14253. * @hidden
  14254. */
  14255. protected _getEffectiveParent(): Nullable<Node>;
  14256. /**
  14257. * Computes the world matrix of the node
  14258. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14259. * @returns the world matrix
  14260. */
  14261. computeWorldMatrix(force?: boolean): Matrix;
  14262. protected _afterComputeWorldMatrix(): void;
  14263. /**
  14264. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14265. * @param func callback function to add
  14266. *
  14267. * @returns the TransformNode.
  14268. */
  14269. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14270. /**
  14271. * Removes a registered callback function.
  14272. * @param func callback function to remove
  14273. * @returns the TransformNode.
  14274. */
  14275. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14276. /**
  14277. * Gets the position of the current mesh in camera space
  14278. * @param camera defines the camera to use
  14279. * @returns a position
  14280. */
  14281. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14282. /**
  14283. * Returns the distance from the mesh to the active camera
  14284. * @param camera defines the camera to use
  14285. * @returns the distance
  14286. */
  14287. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14288. /**
  14289. * Clone the current transform node
  14290. * @param name Name of the new clone
  14291. * @param newParent New parent for the clone
  14292. * @param doNotCloneChildren Do not clone children hierarchy
  14293. * @returns the new transform node
  14294. */
  14295. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14296. /**
  14297. * Serializes the objects information.
  14298. * @param currentSerializationObject defines the object to serialize in
  14299. * @returns the serialized object
  14300. */
  14301. serialize(currentSerializationObject?: any): any;
  14302. /**
  14303. * Returns a new TransformNode object parsed from the source provided.
  14304. * @param parsedTransformNode is the source.
  14305. * @param scene the scne the object belongs to
  14306. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14307. * @returns a new TransformNode object parsed from the source provided.
  14308. */
  14309. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14310. /**
  14311. * Get all child-transformNodes of this node
  14312. * @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
  14313. * @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
  14314. * @returns an array of TransformNode
  14315. */
  14316. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14317. /**
  14318. * Releases resources associated with this transform node.
  14319. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14320. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14321. */
  14322. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14323. /**
  14324. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14325. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14326. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14327. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14328. * @returns the current mesh
  14329. */
  14330. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14331. private _syncAbsoluteScalingAndRotation;
  14332. }
  14333. }
  14334. declare module BABYLON {
  14335. /**
  14336. * Defines the types of pose enabled controllers that are supported
  14337. */
  14338. export enum PoseEnabledControllerType {
  14339. /**
  14340. * HTC Vive
  14341. */
  14342. VIVE = 0,
  14343. /**
  14344. * Oculus Rift
  14345. */
  14346. OCULUS = 1,
  14347. /**
  14348. * Windows mixed reality
  14349. */
  14350. WINDOWS = 2,
  14351. /**
  14352. * Samsung gear VR
  14353. */
  14354. GEAR_VR = 3,
  14355. /**
  14356. * Google Daydream
  14357. */
  14358. DAYDREAM = 4,
  14359. /**
  14360. * Generic
  14361. */
  14362. GENERIC = 5
  14363. }
  14364. /**
  14365. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14366. */
  14367. export interface MutableGamepadButton {
  14368. /**
  14369. * Value of the button/trigger
  14370. */
  14371. value: number;
  14372. /**
  14373. * If the button/trigger is currently touched
  14374. */
  14375. touched: boolean;
  14376. /**
  14377. * If the button/trigger is currently pressed
  14378. */
  14379. pressed: boolean;
  14380. }
  14381. /**
  14382. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14383. * @hidden
  14384. */
  14385. export interface ExtendedGamepadButton extends GamepadButton {
  14386. /**
  14387. * If the button/trigger is currently pressed
  14388. */
  14389. readonly pressed: boolean;
  14390. /**
  14391. * If the button/trigger is currently touched
  14392. */
  14393. readonly touched: boolean;
  14394. /**
  14395. * Value of the button/trigger
  14396. */
  14397. readonly value: number;
  14398. }
  14399. /** @hidden */
  14400. export interface _GamePadFactory {
  14401. /**
  14402. * Returns wether or not the current gamepad can be created for this type of controller.
  14403. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14404. * @returns true if it can be created, otherwise false
  14405. */
  14406. canCreate(gamepadInfo: any): boolean;
  14407. /**
  14408. * Creates a new instance of the Gamepad.
  14409. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14410. * @returns the new gamepad instance
  14411. */
  14412. create(gamepadInfo: any): Gamepad;
  14413. }
  14414. /**
  14415. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14416. */
  14417. export class PoseEnabledControllerHelper {
  14418. /** @hidden */
  14419. static _ControllerFactories: _GamePadFactory[];
  14420. /** @hidden */
  14421. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14422. /**
  14423. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14424. * @param vrGamepad the gamepad to initialized
  14425. * @returns a vr controller of the type the gamepad identified as
  14426. */
  14427. static InitiateController(vrGamepad: any): Gamepad;
  14428. }
  14429. /**
  14430. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14431. */
  14432. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14433. /**
  14434. * If the controller is used in a webXR session
  14435. */
  14436. isXR: boolean;
  14437. private _deviceRoomPosition;
  14438. private _deviceRoomRotationQuaternion;
  14439. /**
  14440. * The device position in babylon space
  14441. */
  14442. devicePosition: Vector3;
  14443. /**
  14444. * The device rotation in babylon space
  14445. */
  14446. deviceRotationQuaternion: Quaternion;
  14447. /**
  14448. * The scale factor of the device in babylon space
  14449. */
  14450. deviceScaleFactor: number;
  14451. /**
  14452. * (Likely devicePosition should be used instead) The device position in its room space
  14453. */
  14454. position: Vector3;
  14455. /**
  14456. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14457. */
  14458. rotationQuaternion: Quaternion;
  14459. /**
  14460. * The type of controller (Eg. Windows mixed reality)
  14461. */
  14462. controllerType: PoseEnabledControllerType;
  14463. protected _calculatedPosition: Vector3;
  14464. private _calculatedRotation;
  14465. /**
  14466. * The raw pose from the device
  14467. */
  14468. rawPose: DevicePose;
  14469. private _trackPosition;
  14470. private _maxRotationDistFromHeadset;
  14471. private _draggedRoomRotation;
  14472. /**
  14473. * @hidden
  14474. */
  14475. _disableTrackPosition(fixedPosition: Vector3): void;
  14476. /**
  14477. * Internal, the mesh attached to the controller
  14478. * @hidden
  14479. */
  14480. _mesh: Nullable<AbstractMesh>;
  14481. private _poseControlledCamera;
  14482. private _leftHandSystemQuaternion;
  14483. /**
  14484. * Internal, matrix used to convert room space to babylon space
  14485. * @hidden
  14486. */
  14487. _deviceToWorld: Matrix;
  14488. /**
  14489. * Node to be used when casting a ray from the controller
  14490. * @hidden
  14491. */
  14492. _pointingPoseNode: Nullable<TransformNode>;
  14493. /**
  14494. * Name of the child mesh that can be used to cast a ray from the controller
  14495. */
  14496. static readonly POINTING_POSE: string;
  14497. /**
  14498. * Creates a new PoseEnabledController from a gamepad
  14499. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14500. */
  14501. constructor(browserGamepad: any);
  14502. private _workingMatrix;
  14503. /**
  14504. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14505. */
  14506. update(): void;
  14507. /**
  14508. * Updates only the pose device and mesh without doing any button event checking
  14509. */
  14510. protected _updatePoseAndMesh(): void;
  14511. /**
  14512. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14513. * @param poseData raw pose fromthe device
  14514. */
  14515. updateFromDevice(poseData: DevicePose): void;
  14516. /**
  14517. * @hidden
  14518. */
  14519. _meshAttachedObservable: Observable<AbstractMesh>;
  14520. /**
  14521. * Attaches a mesh to the controller
  14522. * @param mesh the mesh to be attached
  14523. */
  14524. attachToMesh(mesh: AbstractMesh): void;
  14525. /**
  14526. * Attaches the controllers mesh to a camera
  14527. * @param camera the camera the mesh should be attached to
  14528. */
  14529. attachToPoseControlledCamera(camera: TargetCamera): void;
  14530. /**
  14531. * Disposes of the controller
  14532. */
  14533. dispose(): void;
  14534. /**
  14535. * The mesh that is attached to the controller
  14536. */
  14537. readonly mesh: Nullable<AbstractMesh>;
  14538. /**
  14539. * Gets the ray of the controller in the direction the controller is pointing
  14540. * @param length the length the resulting ray should be
  14541. * @returns a ray in the direction the controller is pointing
  14542. */
  14543. getForwardRay(length?: number): Ray;
  14544. }
  14545. }
  14546. declare module BABYLON {
  14547. /**
  14548. * Defines the WebVRController object that represents controllers tracked in 3D space
  14549. */
  14550. export abstract class WebVRController extends PoseEnabledController {
  14551. /**
  14552. * Internal, the default controller model for the controller
  14553. */
  14554. protected _defaultModel: Nullable<AbstractMesh>;
  14555. /**
  14556. * Fired when the trigger state has changed
  14557. */
  14558. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14559. /**
  14560. * Fired when the main button state has changed
  14561. */
  14562. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14563. /**
  14564. * Fired when the secondary button state has changed
  14565. */
  14566. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14567. /**
  14568. * Fired when the pad state has changed
  14569. */
  14570. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14571. /**
  14572. * Fired when controllers stick values have changed
  14573. */
  14574. onPadValuesChangedObservable: Observable<StickValues>;
  14575. /**
  14576. * Array of button availible on the controller
  14577. */
  14578. protected _buttons: Array<MutableGamepadButton>;
  14579. private _onButtonStateChange;
  14580. /**
  14581. * Fired when a controller button's state has changed
  14582. * @param callback the callback containing the button that was modified
  14583. */
  14584. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14585. /**
  14586. * X and Y axis corresponding to the controllers joystick
  14587. */
  14588. pad: StickValues;
  14589. /**
  14590. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14591. */
  14592. hand: string;
  14593. /**
  14594. * The default controller model for the controller
  14595. */
  14596. readonly defaultModel: Nullable<AbstractMesh>;
  14597. /**
  14598. * Creates a new WebVRController from a gamepad
  14599. * @param vrGamepad the gamepad that the WebVRController should be created from
  14600. */
  14601. constructor(vrGamepad: any);
  14602. /**
  14603. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14604. */
  14605. update(): void;
  14606. /**
  14607. * Function to be called when a button is modified
  14608. */
  14609. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14610. /**
  14611. * Loads a mesh and attaches it to the controller
  14612. * @param scene the scene the mesh should be added to
  14613. * @param meshLoaded callback for when the mesh has been loaded
  14614. */
  14615. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14616. private _setButtonValue;
  14617. private _changes;
  14618. private _checkChanges;
  14619. /**
  14620. * Disposes of th webVRCOntroller
  14621. */
  14622. dispose(): void;
  14623. }
  14624. }
  14625. declare module BABYLON {
  14626. /**
  14627. * The HemisphericLight simulates the ambient environment light,
  14628. * so the passed direction is the light reflection direction, not the incoming direction.
  14629. */
  14630. export class HemisphericLight extends Light {
  14631. /**
  14632. * The groundColor is the light in the opposite direction to the one specified during creation.
  14633. * 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.
  14634. */
  14635. groundColor: Color3;
  14636. /**
  14637. * The light reflection direction, not the incoming direction.
  14638. */
  14639. direction: Vector3;
  14640. /**
  14641. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14642. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14643. * The HemisphericLight can't cast shadows.
  14644. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14645. * @param name The friendly name of the light
  14646. * @param direction The direction of the light reflection
  14647. * @param scene The scene the light belongs to
  14648. */
  14649. constructor(name: string, direction: Vector3, scene: Scene);
  14650. protected _buildUniformLayout(): void;
  14651. /**
  14652. * Returns the string "HemisphericLight".
  14653. * @return The class name
  14654. */
  14655. getClassName(): string;
  14656. /**
  14657. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14658. * Returns the updated direction.
  14659. * @param target The target the direction should point to
  14660. * @return The computed direction
  14661. */
  14662. setDirectionToTarget(target: Vector3): Vector3;
  14663. /**
  14664. * Returns the shadow generator associated to the light.
  14665. * @returns Always null for hemispheric lights because it does not support shadows.
  14666. */
  14667. getShadowGenerator(): Nullable<IShadowGenerator>;
  14668. /**
  14669. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14670. * @param effect The effect to update
  14671. * @param lightIndex The index of the light in the effect to update
  14672. * @returns The hemispheric light
  14673. */
  14674. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14675. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14676. /**
  14677. * Computes the world matrix of the node
  14678. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14679. * @param useWasUpdatedFlag defines a reserved property
  14680. * @returns the world matrix
  14681. */
  14682. computeWorldMatrix(): Matrix;
  14683. /**
  14684. * Returns the integer 3.
  14685. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14686. */
  14687. getTypeID(): number;
  14688. /**
  14689. * Prepares the list of defines specific to the light type.
  14690. * @param defines the list of defines
  14691. * @param lightIndex defines the index of the light for the effect
  14692. */
  14693. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14694. }
  14695. }
  14696. declare module BABYLON {
  14697. /** @hidden */
  14698. export var vrMultiviewToSingleviewPixelShader: {
  14699. name: string;
  14700. shader: string;
  14701. };
  14702. }
  14703. declare module BABYLON {
  14704. /**
  14705. * Renders to multiple views with a single draw call
  14706. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14707. */
  14708. export class MultiviewRenderTarget extends RenderTargetTexture {
  14709. /**
  14710. * Creates a multiview render target
  14711. * @param scene scene used with the render target
  14712. * @param size the size of the render target (used for each view)
  14713. */
  14714. constructor(scene: Scene, size?: number | {
  14715. width: number;
  14716. height: number;
  14717. } | {
  14718. ratio: number;
  14719. });
  14720. /**
  14721. * @hidden
  14722. * @param faceIndex the face index, if its a cube texture
  14723. */
  14724. _bindFrameBuffer(faceIndex?: number): void;
  14725. /**
  14726. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14727. * @returns the view count
  14728. */
  14729. getViewCount(): number;
  14730. }
  14731. }
  14732. declare module BABYLON {
  14733. /**
  14734. * Represents a camera frustum
  14735. */
  14736. export class Frustum {
  14737. /**
  14738. * Gets the planes representing the frustum
  14739. * @param transform matrix to be applied to the returned planes
  14740. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14741. */
  14742. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14743. /**
  14744. * Gets the near frustum plane transformed by the transform matrix
  14745. * @param transform transformation matrix to be applied to the resulting frustum plane
  14746. * @param frustumPlane the resuling frustum plane
  14747. */
  14748. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14749. /**
  14750. * Gets the far frustum plane transformed by the transform matrix
  14751. * @param transform transformation matrix to be applied to the resulting frustum plane
  14752. * @param frustumPlane the resuling frustum plane
  14753. */
  14754. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14755. /**
  14756. * Gets the left frustum plane transformed by the transform matrix
  14757. * @param transform transformation matrix to be applied to the resulting frustum plane
  14758. * @param frustumPlane the resuling frustum plane
  14759. */
  14760. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14761. /**
  14762. * Gets the right frustum plane transformed by the transform matrix
  14763. * @param transform transformation matrix to be applied to the resulting frustum plane
  14764. * @param frustumPlane the resuling frustum plane
  14765. */
  14766. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14767. /**
  14768. * Gets the top frustum plane transformed by the transform matrix
  14769. * @param transform transformation matrix to be applied to the resulting frustum plane
  14770. * @param frustumPlane the resuling frustum plane
  14771. */
  14772. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14773. /**
  14774. * Gets the bottom frustum plane transformed by the transform matrix
  14775. * @param transform transformation matrix to be applied to the resulting frustum plane
  14776. * @param frustumPlane the resuling frustum plane
  14777. */
  14778. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14779. /**
  14780. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14781. * @param transform transformation matrix to be applied to the resulting frustum planes
  14782. * @param frustumPlanes the resuling frustum planes
  14783. */
  14784. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14785. }
  14786. }
  14787. declare module BABYLON {
  14788. interface Engine {
  14789. /**
  14790. * Creates a new multiview render target
  14791. * @param width defines the width of the texture
  14792. * @param height defines the height of the texture
  14793. * @returns the created multiview texture
  14794. */
  14795. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14796. /**
  14797. * Binds a multiview framebuffer to be drawn to
  14798. * @param multiviewTexture texture to bind
  14799. */
  14800. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14801. }
  14802. interface Camera {
  14803. /**
  14804. * @hidden
  14805. * 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)
  14806. */
  14807. _useMultiviewToSingleView: boolean;
  14808. /**
  14809. * @hidden
  14810. * 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)
  14811. */
  14812. _multiviewTexture: Nullable<RenderTargetTexture>;
  14813. /**
  14814. * @hidden
  14815. * ensures the multiview texture of the camera exists and has the specified width/height
  14816. * @param width height to set on the multiview texture
  14817. * @param height width to set on the multiview texture
  14818. */
  14819. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14820. }
  14821. interface Scene {
  14822. /** @hidden */
  14823. _transformMatrixR: Matrix;
  14824. /** @hidden */
  14825. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14826. /** @hidden */
  14827. _createMultiviewUbo(): void;
  14828. /** @hidden */
  14829. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14830. /** @hidden */
  14831. _renderMultiviewToSingleView(camera: Camera): void;
  14832. }
  14833. }
  14834. declare module BABYLON {
  14835. /**
  14836. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14837. * This will not be used for webXR as it supports displaying texture arrays directly
  14838. */
  14839. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14840. /**
  14841. * Initializes a VRMultiviewToSingleview
  14842. * @param name name of the post process
  14843. * @param camera camera to be applied to
  14844. * @param scaleFactor scaling factor to the size of the output texture
  14845. */
  14846. constructor(name: string, camera: Camera, scaleFactor: number);
  14847. }
  14848. }
  14849. declare module BABYLON {
  14850. interface Engine {
  14851. /** @hidden */
  14852. _vrDisplay: any;
  14853. /** @hidden */
  14854. _vrSupported: boolean;
  14855. /** @hidden */
  14856. _oldSize: Size;
  14857. /** @hidden */
  14858. _oldHardwareScaleFactor: number;
  14859. /** @hidden */
  14860. _vrExclusivePointerMode: boolean;
  14861. /** @hidden */
  14862. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14863. /** @hidden */
  14864. _onVRDisplayPointerRestricted: () => void;
  14865. /** @hidden */
  14866. _onVRDisplayPointerUnrestricted: () => void;
  14867. /** @hidden */
  14868. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14869. /** @hidden */
  14870. _onVrDisplayDisconnect: Nullable<() => void>;
  14871. /** @hidden */
  14872. _onVrDisplayPresentChange: Nullable<() => void>;
  14873. /**
  14874. * Observable signaled when VR display mode changes
  14875. */
  14876. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14877. /**
  14878. * Observable signaled when VR request present is complete
  14879. */
  14880. onVRRequestPresentComplete: Observable<boolean>;
  14881. /**
  14882. * Observable signaled when VR request present starts
  14883. */
  14884. onVRRequestPresentStart: Observable<Engine>;
  14885. /**
  14886. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14887. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14888. */
  14889. isInVRExclusivePointerMode: boolean;
  14890. /**
  14891. * Gets a boolean indicating if a webVR device was detected
  14892. * @returns true if a webVR device was detected
  14893. */
  14894. isVRDevicePresent(): boolean;
  14895. /**
  14896. * Gets the current webVR device
  14897. * @returns the current webVR device (or null)
  14898. */
  14899. getVRDevice(): any;
  14900. /**
  14901. * Initializes a webVR display and starts listening to display change events
  14902. * The onVRDisplayChangedObservable will be notified upon these changes
  14903. * @returns A promise containing a VRDisplay and if vr is supported
  14904. */
  14905. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14906. /** @hidden */
  14907. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14908. /**
  14909. * Call this function to switch to webVR mode
  14910. * Will do nothing if webVR is not supported or if there is no webVR device
  14911. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14912. */
  14913. enableVR(): void;
  14914. /** @hidden */
  14915. _onVRFullScreenTriggered(): void;
  14916. }
  14917. }
  14918. declare module BABYLON {
  14919. /**
  14920. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14921. * IMPORTANT!! The data is right-hand data.
  14922. * @export
  14923. * @interface DevicePose
  14924. */
  14925. export interface DevicePose {
  14926. /**
  14927. * The position of the device, values in array are [x,y,z].
  14928. */
  14929. readonly position: Nullable<Float32Array>;
  14930. /**
  14931. * The linearVelocity of the device, values in array are [x,y,z].
  14932. */
  14933. readonly linearVelocity: Nullable<Float32Array>;
  14934. /**
  14935. * The linearAcceleration of the device, values in array are [x,y,z].
  14936. */
  14937. readonly linearAcceleration: Nullable<Float32Array>;
  14938. /**
  14939. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14940. */
  14941. readonly orientation: Nullable<Float32Array>;
  14942. /**
  14943. * The angularVelocity of the device, values in array are [x,y,z].
  14944. */
  14945. readonly angularVelocity: Nullable<Float32Array>;
  14946. /**
  14947. * The angularAcceleration of the device, values in array are [x,y,z].
  14948. */
  14949. readonly angularAcceleration: Nullable<Float32Array>;
  14950. }
  14951. /**
  14952. * Interface representing a pose controlled object in Babylon.
  14953. * A pose controlled object has both regular pose values as well as pose values
  14954. * from an external device such as a VR head mounted display
  14955. */
  14956. export interface PoseControlled {
  14957. /**
  14958. * The position of the object in babylon space.
  14959. */
  14960. position: Vector3;
  14961. /**
  14962. * The rotation quaternion of the object in babylon space.
  14963. */
  14964. rotationQuaternion: Quaternion;
  14965. /**
  14966. * The position of the device in babylon space.
  14967. */
  14968. devicePosition?: Vector3;
  14969. /**
  14970. * The rotation quaternion of the device in babylon space.
  14971. */
  14972. deviceRotationQuaternion: Quaternion;
  14973. /**
  14974. * The raw pose coming from the device.
  14975. */
  14976. rawPose: Nullable<DevicePose>;
  14977. /**
  14978. * The scale of the device to be used when translating from device space to babylon space.
  14979. */
  14980. deviceScaleFactor: number;
  14981. /**
  14982. * Updates the poseControlled values based on the input device pose.
  14983. * @param poseData the pose data to update the object with
  14984. */
  14985. updateFromDevice(poseData: DevicePose): void;
  14986. }
  14987. /**
  14988. * Set of options to customize the webVRCamera
  14989. */
  14990. export interface WebVROptions {
  14991. /**
  14992. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14993. */
  14994. trackPosition?: boolean;
  14995. /**
  14996. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14997. */
  14998. positionScale?: number;
  14999. /**
  15000. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15001. */
  15002. displayName?: string;
  15003. /**
  15004. * Should the native controller meshes be initialized. (default: true)
  15005. */
  15006. controllerMeshes?: boolean;
  15007. /**
  15008. * Creating a default HemiLight only on controllers. (default: true)
  15009. */
  15010. defaultLightingOnControllers?: boolean;
  15011. /**
  15012. * If you don't want to use the default VR button of the helper. (default: false)
  15013. */
  15014. useCustomVRButton?: boolean;
  15015. /**
  15016. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15017. */
  15018. customVRButton?: HTMLButtonElement;
  15019. /**
  15020. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15021. */
  15022. rayLength?: number;
  15023. /**
  15024. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15025. */
  15026. defaultHeight?: number;
  15027. /**
  15028. * If multiview should be used if availible (default: false)
  15029. */
  15030. useMultiview?: boolean;
  15031. }
  15032. /**
  15033. * This represents a WebVR camera.
  15034. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15035. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15036. */
  15037. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15038. private webVROptions;
  15039. /**
  15040. * @hidden
  15041. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15042. */
  15043. _vrDevice: any;
  15044. /**
  15045. * The rawPose of the vrDevice.
  15046. */
  15047. rawPose: Nullable<DevicePose>;
  15048. private _onVREnabled;
  15049. private _specsVersion;
  15050. private _attached;
  15051. private _frameData;
  15052. protected _descendants: Array<Node>;
  15053. private _deviceRoomPosition;
  15054. /** @hidden */
  15055. _deviceRoomRotationQuaternion: Quaternion;
  15056. private _standingMatrix;
  15057. /**
  15058. * Represents device position in babylon space.
  15059. */
  15060. devicePosition: Vector3;
  15061. /**
  15062. * Represents device rotation in babylon space.
  15063. */
  15064. deviceRotationQuaternion: Quaternion;
  15065. /**
  15066. * The scale of the device to be used when translating from device space to babylon space.
  15067. */
  15068. deviceScaleFactor: number;
  15069. private _deviceToWorld;
  15070. private _worldToDevice;
  15071. /**
  15072. * References to the webVR controllers for the vrDevice.
  15073. */
  15074. controllers: Array<WebVRController>;
  15075. /**
  15076. * Emits an event when a controller is attached.
  15077. */
  15078. onControllersAttachedObservable: Observable<WebVRController[]>;
  15079. /**
  15080. * Emits an event when a controller's mesh has been loaded;
  15081. */
  15082. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15083. /**
  15084. * Emits an event when the HMD's pose has been updated.
  15085. */
  15086. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15087. private _poseSet;
  15088. /**
  15089. * If the rig cameras be used as parent instead of this camera.
  15090. */
  15091. rigParenting: boolean;
  15092. private _lightOnControllers;
  15093. private _defaultHeight?;
  15094. /**
  15095. * Instantiates a WebVRFreeCamera.
  15096. * @param name The name of the WebVRFreeCamera
  15097. * @param position The starting anchor position for the camera
  15098. * @param scene The scene the camera belongs to
  15099. * @param webVROptions a set of customizable options for the webVRCamera
  15100. */
  15101. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15102. /**
  15103. * Gets the device distance from the ground in meters.
  15104. * @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.
  15105. */
  15106. deviceDistanceToRoomGround(): number;
  15107. /**
  15108. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15109. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15110. */
  15111. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15112. /**
  15113. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15114. * @returns A promise with a boolean set to if the standing matrix is supported.
  15115. */
  15116. useStandingMatrixAsync(): Promise<boolean>;
  15117. /**
  15118. * Disposes the camera
  15119. */
  15120. dispose(): void;
  15121. /**
  15122. * Gets a vrController by name.
  15123. * @param name The name of the controller to retreive
  15124. * @returns the controller matching the name specified or null if not found
  15125. */
  15126. getControllerByName(name: string): Nullable<WebVRController>;
  15127. private _leftController;
  15128. /**
  15129. * The controller corresponding to the users left hand.
  15130. */
  15131. readonly leftController: Nullable<WebVRController>;
  15132. private _rightController;
  15133. /**
  15134. * The controller corresponding to the users right hand.
  15135. */
  15136. readonly rightController: Nullable<WebVRController>;
  15137. /**
  15138. * Casts a ray forward from the vrCamera's gaze.
  15139. * @param length Length of the ray (default: 100)
  15140. * @returns the ray corresponding to the gaze
  15141. */
  15142. getForwardRay(length?: number): Ray;
  15143. /**
  15144. * @hidden
  15145. * Updates the camera based on device's frame data
  15146. */
  15147. _checkInputs(): void;
  15148. /**
  15149. * Updates the poseControlled values based on the input device pose.
  15150. * @param poseData Pose coming from the device
  15151. */
  15152. updateFromDevice(poseData: DevicePose): void;
  15153. private _htmlElementAttached;
  15154. private _detachIfAttached;
  15155. /**
  15156. * WebVR's attach control will start broadcasting frames to the device.
  15157. * Note that in certain browsers (chrome for example) this function must be called
  15158. * within a user-interaction callback. Example:
  15159. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15160. *
  15161. * @param element html element to attach the vrDevice to
  15162. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15163. */
  15164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15165. /**
  15166. * Detaches the camera from the html element and disables VR
  15167. *
  15168. * @param element html element to detach from
  15169. */
  15170. detachControl(element: HTMLElement): void;
  15171. /**
  15172. * @returns the name of this class
  15173. */
  15174. getClassName(): string;
  15175. /**
  15176. * Calls resetPose on the vrDisplay
  15177. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15178. */
  15179. resetToCurrentRotation(): void;
  15180. /**
  15181. * @hidden
  15182. * Updates the rig cameras (left and right eye)
  15183. */
  15184. _updateRigCameras(): void;
  15185. private _workingVector;
  15186. private _oneVector;
  15187. private _workingMatrix;
  15188. private updateCacheCalled;
  15189. private _correctPositionIfNotTrackPosition;
  15190. /**
  15191. * @hidden
  15192. * Updates the cached values of the camera
  15193. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15194. */
  15195. _updateCache(ignoreParentClass?: boolean): void;
  15196. /**
  15197. * @hidden
  15198. * Get current device position in babylon world
  15199. */
  15200. _computeDevicePosition(): void;
  15201. /**
  15202. * Updates the current device position and rotation in the babylon world
  15203. */
  15204. update(): void;
  15205. /**
  15206. * @hidden
  15207. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15208. * @returns an identity matrix
  15209. */
  15210. _getViewMatrix(): Matrix;
  15211. private _tmpMatrix;
  15212. /**
  15213. * This function is called by the two RIG cameras.
  15214. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15215. * @hidden
  15216. */
  15217. _getWebVRViewMatrix(): Matrix;
  15218. /** @hidden */
  15219. _getWebVRProjectionMatrix(): Matrix;
  15220. private _onGamepadConnectedObserver;
  15221. private _onGamepadDisconnectedObserver;
  15222. private _updateCacheWhenTrackingDisabledObserver;
  15223. /**
  15224. * Initializes the controllers and their meshes
  15225. */
  15226. initControllers(): void;
  15227. }
  15228. }
  15229. declare module BABYLON {
  15230. /**
  15231. * Size options for a post process
  15232. */
  15233. export type PostProcessOptions = {
  15234. width: number;
  15235. height: number;
  15236. };
  15237. /**
  15238. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15239. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15240. */
  15241. export class PostProcess {
  15242. /** Name of the PostProcess. */
  15243. name: string;
  15244. /**
  15245. * Gets or sets the unique id of the post process
  15246. */
  15247. uniqueId: number;
  15248. /**
  15249. * Width of the texture to apply the post process on
  15250. */
  15251. width: number;
  15252. /**
  15253. * Height of the texture to apply the post process on
  15254. */
  15255. height: number;
  15256. /**
  15257. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15258. * @hidden
  15259. */
  15260. _outputTexture: Nullable<InternalTexture>;
  15261. /**
  15262. * Sampling mode used by the shader
  15263. * See https://doc.babylonjs.com/classes/3.1/texture
  15264. */
  15265. renderTargetSamplingMode: number;
  15266. /**
  15267. * Clear color to use when screen clearing
  15268. */
  15269. clearColor: Color4;
  15270. /**
  15271. * If the buffer needs to be cleared before applying the post process. (default: true)
  15272. * Should be set to false if shader will overwrite all previous pixels.
  15273. */
  15274. autoClear: boolean;
  15275. /**
  15276. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15277. */
  15278. alphaMode: number;
  15279. /**
  15280. * Sets the setAlphaBlendConstants of the babylon engine
  15281. */
  15282. alphaConstants: Color4;
  15283. /**
  15284. * Animations to be used for the post processing
  15285. */
  15286. animations: Animation[];
  15287. /**
  15288. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15289. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15290. */
  15291. enablePixelPerfectMode: boolean;
  15292. /**
  15293. * Force the postprocess to be applied without taking in account viewport
  15294. */
  15295. forceFullscreenViewport: boolean;
  15296. /**
  15297. * List of inspectable custom properties (used by the Inspector)
  15298. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15299. */
  15300. inspectableCustomProperties: IInspectable[];
  15301. /**
  15302. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15303. *
  15304. * | Value | Type | Description |
  15305. * | ----- | ----------------------------------- | ----------- |
  15306. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15307. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15308. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15309. *
  15310. */
  15311. scaleMode: number;
  15312. /**
  15313. * Force textures to be a power of two (default: false)
  15314. */
  15315. alwaysForcePOT: boolean;
  15316. private _samples;
  15317. /**
  15318. * Number of sample textures (default: 1)
  15319. */
  15320. samples: number;
  15321. /**
  15322. * Modify the scale of the post process to be the same as the viewport (default: false)
  15323. */
  15324. adaptScaleToCurrentViewport: boolean;
  15325. private _camera;
  15326. private _scene;
  15327. private _engine;
  15328. private _options;
  15329. private _reusable;
  15330. private _textureType;
  15331. /**
  15332. * Smart array of input and output textures for the post process.
  15333. * @hidden
  15334. */
  15335. _textures: SmartArray<InternalTexture>;
  15336. /**
  15337. * The index in _textures that corresponds to the output texture.
  15338. * @hidden
  15339. */
  15340. _currentRenderTextureInd: number;
  15341. private _effect;
  15342. private _samplers;
  15343. private _fragmentUrl;
  15344. private _vertexUrl;
  15345. private _parameters;
  15346. private _scaleRatio;
  15347. protected _indexParameters: any;
  15348. private _shareOutputWithPostProcess;
  15349. private _texelSize;
  15350. private _forcedOutputTexture;
  15351. /**
  15352. * Returns the fragment url or shader name used in the post process.
  15353. * @returns the fragment url or name in the shader store.
  15354. */
  15355. getEffectName(): string;
  15356. /**
  15357. * An event triggered when the postprocess is activated.
  15358. */
  15359. onActivateObservable: Observable<Camera>;
  15360. private _onActivateObserver;
  15361. /**
  15362. * A function that is added to the onActivateObservable
  15363. */
  15364. onActivate: Nullable<(camera: Camera) => void>;
  15365. /**
  15366. * An event triggered when the postprocess changes its size.
  15367. */
  15368. onSizeChangedObservable: Observable<PostProcess>;
  15369. private _onSizeChangedObserver;
  15370. /**
  15371. * A function that is added to the onSizeChangedObservable
  15372. */
  15373. onSizeChanged: (postProcess: PostProcess) => void;
  15374. /**
  15375. * An event triggered when the postprocess applies its effect.
  15376. */
  15377. onApplyObservable: Observable<Effect>;
  15378. private _onApplyObserver;
  15379. /**
  15380. * A function that is added to the onApplyObservable
  15381. */
  15382. onApply: (effect: Effect) => void;
  15383. /**
  15384. * An event triggered before rendering the postprocess
  15385. */
  15386. onBeforeRenderObservable: Observable<Effect>;
  15387. private _onBeforeRenderObserver;
  15388. /**
  15389. * A function that is added to the onBeforeRenderObservable
  15390. */
  15391. onBeforeRender: (effect: Effect) => void;
  15392. /**
  15393. * An event triggered after rendering the postprocess
  15394. */
  15395. onAfterRenderObservable: Observable<Effect>;
  15396. private _onAfterRenderObserver;
  15397. /**
  15398. * A function that is added to the onAfterRenderObservable
  15399. */
  15400. onAfterRender: (efect: Effect) => void;
  15401. /**
  15402. * 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
  15403. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15404. */
  15405. inputTexture: InternalTexture;
  15406. /**
  15407. * Gets the camera which post process is applied to.
  15408. * @returns The camera the post process is applied to.
  15409. */
  15410. getCamera(): Camera;
  15411. /**
  15412. * Gets the texel size of the postprocess.
  15413. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15414. */
  15415. readonly texelSize: Vector2;
  15416. /**
  15417. * Creates a new instance PostProcess
  15418. * @param name The name of the PostProcess.
  15419. * @param fragmentUrl The url of the fragment shader to be used.
  15420. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15421. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15422. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15423. * @param camera The camera to apply the render pass to.
  15424. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15425. * @param engine The engine which the post process will be applied. (default: current engine)
  15426. * @param reusable If the post process can be reused on the same frame. (default: false)
  15427. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15428. * @param textureType Type of textures used when performing the post process. (default: 0)
  15429. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15430. * @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
  15431. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15432. */
  15433. constructor(
  15434. /** Name of the PostProcess. */
  15435. 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);
  15436. /**
  15437. * Gets a string idenfifying the name of the class
  15438. * @returns "PostProcess" string
  15439. */
  15440. getClassName(): string;
  15441. /**
  15442. * Gets the engine which this post process belongs to.
  15443. * @returns The engine the post process was enabled with.
  15444. */
  15445. getEngine(): Engine;
  15446. /**
  15447. * The effect that is created when initializing the post process.
  15448. * @returns The created effect corresponding the the postprocess.
  15449. */
  15450. getEffect(): Effect;
  15451. /**
  15452. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15453. * @param postProcess The post process to share the output with.
  15454. * @returns This post process.
  15455. */
  15456. shareOutputWith(postProcess: PostProcess): PostProcess;
  15457. /**
  15458. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15459. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15460. */
  15461. useOwnOutput(): void;
  15462. /**
  15463. * Updates the effect with the current post process compile time values and recompiles the shader.
  15464. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15465. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15466. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15467. * @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
  15468. * @param onCompiled Called when the shader has been compiled.
  15469. * @param onError Called if there is an error when compiling a shader.
  15470. */
  15471. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15472. /**
  15473. * The post process is reusable if it can be used multiple times within one frame.
  15474. * @returns If the post process is reusable
  15475. */
  15476. isReusable(): boolean;
  15477. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15478. markTextureDirty(): void;
  15479. /**
  15480. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15481. * 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.
  15482. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15483. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15484. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15485. * @returns The target texture that was bound to be written to.
  15486. */
  15487. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15488. /**
  15489. * If the post process is supported.
  15490. */
  15491. readonly isSupported: boolean;
  15492. /**
  15493. * The aspect ratio of the output texture.
  15494. */
  15495. readonly aspectRatio: number;
  15496. /**
  15497. * Get a value indicating if the post-process is ready to be used
  15498. * @returns true if the post-process is ready (shader is compiled)
  15499. */
  15500. isReady(): boolean;
  15501. /**
  15502. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15503. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15504. */
  15505. apply(): Nullable<Effect>;
  15506. private _disposeTextures;
  15507. /**
  15508. * Disposes the post process.
  15509. * @param camera The camera to dispose the post process on.
  15510. */
  15511. dispose(camera?: Camera): void;
  15512. }
  15513. }
  15514. declare module BABYLON {
  15515. /** @hidden */
  15516. export var kernelBlurVaryingDeclaration: {
  15517. name: string;
  15518. shader: string;
  15519. };
  15520. }
  15521. declare module BABYLON {
  15522. /** @hidden */
  15523. export var kernelBlurFragment: {
  15524. name: string;
  15525. shader: string;
  15526. };
  15527. }
  15528. declare module BABYLON {
  15529. /** @hidden */
  15530. export var kernelBlurFragment2: {
  15531. name: string;
  15532. shader: string;
  15533. };
  15534. }
  15535. declare module BABYLON {
  15536. /** @hidden */
  15537. export var kernelBlurPixelShader: {
  15538. name: string;
  15539. shader: string;
  15540. };
  15541. }
  15542. declare module BABYLON {
  15543. /** @hidden */
  15544. export var kernelBlurVertex: {
  15545. name: string;
  15546. shader: string;
  15547. };
  15548. }
  15549. declare module BABYLON {
  15550. /** @hidden */
  15551. export var kernelBlurVertexShader: {
  15552. name: string;
  15553. shader: string;
  15554. };
  15555. }
  15556. declare module BABYLON {
  15557. /**
  15558. * The Blur Post Process which blurs an image based on a kernel and direction.
  15559. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15560. */
  15561. export class BlurPostProcess extends PostProcess {
  15562. /** The direction in which to blur the image. */
  15563. direction: Vector2;
  15564. private blockCompilation;
  15565. protected _kernel: number;
  15566. protected _idealKernel: number;
  15567. protected _packedFloat: boolean;
  15568. private _staticDefines;
  15569. /**
  15570. * Sets the length in pixels of the blur sample region
  15571. */
  15572. /**
  15573. * Gets the length in pixels of the blur sample region
  15574. */
  15575. kernel: number;
  15576. /**
  15577. * Sets wether or not the blur needs to unpack/repack floats
  15578. */
  15579. /**
  15580. * Gets wether or not the blur is unpacking/repacking floats
  15581. */
  15582. packedFloat: boolean;
  15583. /**
  15584. * Creates a new instance BlurPostProcess
  15585. * @param name The name of the effect.
  15586. * @param direction The direction in which to blur the image.
  15587. * @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.
  15588. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15589. * @param camera The camera to apply the render pass to.
  15590. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15591. * @param engine The engine which the post process will be applied. (default: current engine)
  15592. * @param reusable If the post process can be reused on the same frame. (default: false)
  15593. * @param textureType Type of textures used when performing the post process. (default: 0)
  15594. * @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)
  15595. */
  15596. constructor(name: string,
  15597. /** The direction in which to blur the image. */
  15598. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15599. /**
  15600. * Updates the effect with the current post process compile time values and recompiles the shader.
  15601. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15602. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15603. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15604. * @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
  15605. * @param onCompiled Called when the shader has been compiled.
  15606. * @param onError Called if there is an error when compiling a shader.
  15607. */
  15608. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15609. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15610. /**
  15611. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15612. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15613. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15614. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15615. * The gaps between physical kernels are compensated for in the weighting of the samples
  15616. * @param idealKernel Ideal blur kernel.
  15617. * @return Nearest best kernel.
  15618. */
  15619. protected _nearestBestKernel(idealKernel: number): number;
  15620. /**
  15621. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15622. * @param x The point on the Gaussian distribution to sample.
  15623. * @return the value of the Gaussian function at x.
  15624. */
  15625. protected _gaussianWeight(x: number): number;
  15626. /**
  15627. * Generates a string that can be used as a floating point number in GLSL.
  15628. * @param x Value to print.
  15629. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15630. * @return GLSL float string.
  15631. */
  15632. protected _glslFloat(x: number, decimalFigures?: number): string;
  15633. }
  15634. }
  15635. declare module BABYLON {
  15636. /**
  15637. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15638. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15639. * You can then easily use it as a reflectionTexture on a flat surface.
  15640. * In case the surface is not a plane, please consider relying on reflection probes.
  15641. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15642. */
  15643. export class MirrorTexture extends RenderTargetTexture {
  15644. private scene;
  15645. /**
  15646. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15647. * 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.
  15648. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15649. */
  15650. mirrorPlane: Plane;
  15651. /**
  15652. * Define the blur ratio used to blur the reflection if needed.
  15653. */
  15654. blurRatio: number;
  15655. /**
  15656. * Define the adaptive blur kernel used to blur the reflection if needed.
  15657. * This will autocompute the closest best match for the `blurKernel`
  15658. */
  15659. adaptiveBlurKernel: number;
  15660. /**
  15661. * Define the blur kernel used to blur the reflection if needed.
  15662. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15663. */
  15664. blurKernel: number;
  15665. /**
  15666. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15667. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15668. */
  15669. blurKernelX: number;
  15670. /**
  15671. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15672. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15673. */
  15674. blurKernelY: number;
  15675. private _autoComputeBlurKernel;
  15676. protected _onRatioRescale(): void;
  15677. private _updateGammaSpace;
  15678. private _imageProcessingConfigChangeObserver;
  15679. private _transformMatrix;
  15680. private _mirrorMatrix;
  15681. private _savedViewMatrix;
  15682. private _blurX;
  15683. private _blurY;
  15684. private _adaptiveBlurKernel;
  15685. private _blurKernelX;
  15686. private _blurKernelY;
  15687. private _blurRatio;
  15688. /**
  15689. * Instantiates a Mirror Texture.
  15690. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15691. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15692. * You can then easily use it as a reflectionTexture on a flat surface.
  15693. * In case the surface is not a plane, please consider relying on reflection probes.
  15694. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15695. * @param name
  15696. * @param size
  15697. * @param scene
  15698. * @param generateMipMaps
  15699. * @param type
  15700. * @param samplingMode
  15701. * @param generateDepthBuffer
  15702. */
  15703. constructor(name: string, size: number | {
  15704. width: number;
  15705. height: number;
  15706. } | {
  15707. ratio: number;
  15708. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15709. private _preparePostProcesses;
  15710. /**
  15711. * Clone the mirror texture.
  15712. * @returns the cloned texture
  15713. */
  15714. clone(): MirrorTexture;
  15715. /**
  15716. * Serialize the texture to a JSON representation you could use in Parse later on
  15717. * @returns the serialized JSON representation
  15718. */
  15719. serialize(): any;
  15720. /**
  15721. * Dispose the texture and release its associated resources.
  15722. */
  15723. dispose(): void;
  15724. }
  15725. }
  15726. declare module BABYLON {
  15727. /**
  15728. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15729. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15730. */
  15731. export class Texture extends BaseTexture {
  15732. /**
  15733. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15734. */
  15735. static SerializeBuffers: boolean;
  15736. /** @hidden */
  15737. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15738. /** @hidden */
  15739. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15740. /** @hidden */
  15741. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15742. /** nearest is mag = nearest and min = nearest and mip = linear */
  15743. static readonly NEAREST_SAMPLINGMODE: number;
  15744. /** nearest is mag = nearest and min = nearest and mip = linear */
  15745. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15746. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15747. static readonly BILINEAR_SAMPLINGMODE: number;
  15748. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15749. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15750. /** Trilinear is mag = linear and min = linear and mip = linear */
  15751. static readonly TRILINEAR_SAMPLINGMODE: number;
  15752. /** Trilinear is mag = linear and min = linear and mip = linear */
  15753. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15754. /** mag = nearest and min = nearest and mip = nearest */
  15755. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15756. /** mag = nearest and min = linear and mip = nearest */
  15757. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15758. /** mag = nearest and min = linear and mip = linear */
  15759. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15760. /** mag = nearest and min = linear and mip = none */
  15761. static readonly NEAREST_LINEAR: number;
  15762. /** mag = nearest and min = nearest and mip = none */
  15763. static readonly NEAREST_NEAREST: number;
  15764. /** mag = linear and min = nearest and mip = nearest */
  15765. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15766. /** mag = linear and min = nearest and mip = linear */
  15767. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15768. /** mag = linear and min = linear and mip = none */
  15769. static readonly LINEAR_LINEAR: number;
  15770. /** mag = linear and min = nearest and mip = none */
  15771. static readonly LINEAR_NEAREST: number;
  15772. /** Explicit coordinates mode */
  15773. static readonly EXPLICIT_MODE: number;
  15774. /** Spherical coordinates mode */
  15775. static readonly SPHERICAL_MODE: number;
  15776. /** Planar coordinates mode */
  15777. static readonly PLANAR_MODE: number;
  15778. /** Cubic coordinates mode */
  15779. static readonly CUBIC_MODE: number;
  15780. /** Projection coordinates mode */
  15781. static readonly PROJECTION_MODE: number;
  15782. /** Inverse Cubic coordinates mode */
  15783. static readonly SKYBOX_MODE: number;
  15784. /** Inverse Cubic coordinates mode */
  15785. static readonly INVCUBIC_MODE: number;
  15786. /** Equirectangular coordinates mode */
  15787. static readonly EQUIRECTANGULAR_MODE: number;
  15788. /** Equirectangular Fixed coordinates mode */
  15789. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15790. /** Equirectangular Fixed Mirrored coordinates mode */
  15791. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15792. /** Texture is not repeating outside of 0..1 UVs */
  15793. static readonly CLAMP_ADDRESSMODE: number;
  15794. /** Texture is repeating outside of 0..1 UVs */
  15795. static readonly WRAP_ADDRESSMODE: number;
  15796. /** Texture is repeating and mirrored */
  15797. static readonly MIRROR_ADDRESSMODE: number;
  15798. /**
  15799. * 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
  15800. */
  15801. static UseSerializedUrlIfAny: boolean;
  15802. /**
  15803. * Define the url of the texture.
  15804. */
  15805. url: Nullable<string>;
  15806. /**
  15807. * Define an offset on the texture to offset the u coordinates of the UVs
  15808. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15809. */
  15810. uOffset: number;
  15811. /**
  15812. * Define an offset on the texture to offset the v coordinates of the UVs
  15813. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15814. */
  15815. vOffset: number;
  15816. /**
  15817. * Define an offset on the texture to scale the u coordinates of the UVs
  15818. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15819. */
  15820. uScale: number;
  15821. /**
  15822. * Define an offset on the texture to scale the v coordinates of the UVs
  15823. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15824. */
  15825. vScale: number;
  15826. /**
  15827. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15828. * @see http://doc.babylonjs.com/how_to/more_materials
  15829. */
  15830. uAng: number;
  15831. /**
  15832. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15833. * @see http://doc.babylonjs.com/how_to/more_materials
  15834. */
  15835. vAng: number;
  15836. /**
  15837. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15838. * @see http://doc.babylonjs.com/how_to/more_materials
  15839. */
  15840. wAng: number;
  15841. /**
  15842. * Defines the center of rotation (U)
  15843. */
  15844. uRotationCenter: number;
  15845. /**
  15846. * Defines the center of rotation (V)
  15847. */
  15848. vRotationCenter: number;
  15849. /**
  15850. * Defines the center of rotation (W)
  15851. */
  15852. wRotationCenter: number;
  15853. /**
  15854. * Are mip maps generated for this texture or not.
  15855. */
  15856. readonly noMipmap: boolean;
  15857. /**
  15858. * List of inspectable custom properties (used by the Inspector)
  15859. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15860. */
  15861. inspectableCustomProperties: Nullable<IInspectable[]>;
  15862. private _noMipmap;
  15863. /** @hidden */
  15864. _invertY: boolean;
  15865. private _rowGenerationMatrix;
  15866. private _cachedTextureMatrix;
  15867. private _projectionModeMatrix;
  15868. private _t0;
  15869. private _t1;
  15870. private _t2;
  15871. private _cachedUOffset;
  15872. private _cachedVOffset;
  15873. private _cachedUScale;
  15874. private _cachedVScale;
  15875. private _cachedUAng;
  15876. private _cachedVAng;
  15877. private _cachedWAng;
  15878. private _cachedProjectionMatrixId;
  15879. private _cachedCoordinatesMode;
  15880. /** @hidden */
  15881. protected _initialSamplingMode: number;
  15882. /** @hidden */
  15883. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15884. private _deleteBuffer;
  15885. protected _format: Nullable<number>;
  15886. private _delayedOnLoad;
  15887. private _delayedOnError;
  15888. /**
  15889. * Observable triggered once the texture has been loaded.
  15890. */
  15891. onLoadObservable: Observable<Texture>;
  15892. protected _isBlocking: boolean;
  15893. /**
  15894. * Is the texture preventing material to render while loading.
  15895. * If false, a default texture will be used instead of the loading one during the preparation step.
  15896. */
  15897. isBlocking: boolean;
  15898. /**
  15899. * Get the current sampling mode associated with the texture.
  15900. */
  15901. readonly samplingMode: number;
  15902. /**
  15903. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15904. */
  15905. readonly invertY: boolean;
  15906. /**
  15907. * Instantiates a new texture.
  15908. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15909. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15910. * @param url define the url of the picture to load as a texture
  15911. * @param scene define the scene or engine the texture will belong to
  15912. * @param noMipmap define if the texture will require mip maps or not
  15913. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15914. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15915. * @param onLoad define a callback triggered when the texture has been loaded
  15916. * @param onError define a callback triggered when an error occurred during the loading session
  15917. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15918. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15919. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15920. */
  15921. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15922. /**
  15923. * Update the url (and optional buffer) of this texture if url was null during construction.
  15924. * @param url the url of the texture
  15925. * @param buffer the buffer of the texture (defaults to null)
  15926. * @param onLoad callback called when the texture is loaded (defaults to null)
  15927. */
  15928. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15929. /**
  15930. * Finish the loading sequence of a texture flagged as delayed load.
  15931. * @hidden
  15932. */
  15933. delayLoad(): void;
  15934. private _prepareRowForTextureGeneration;
  15935. /**
  15936. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15937. * @returns the transform matrix of the texture.
  15938. */
  15939. getTextureMatrix(): Matrix;
  15940. /**
  15941. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15942. * @returns The reflection texture transform
  15943. */
  15944. getReflectionTextureMatrix(): Matrix;
  15945. /**
  15946. * Clones the texture.
  15947. * @returns the cloned texture
  15948. */
  15949. clone(): Texture;
  15950. /**
  15951. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15952. * @returns The JSON representation of the texture
  15953. */
  15954. serialize(): any;
  15955. /**
  15956. * Get the current class name of the texture useful for serialization or dynamic coding.
  15957. * @returns "Texture"
  15958. */
  15959. getClassName(): string;
  15960. /**
  15961. * Dispose the texture and release its associated resources.
  15962. */
  15963. dispose(): void;
  15964. /**
  15965. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15966. * @param parsedTexture Define the JSON representation of the texture
  15967. * @param scene Define the scene the parsed texture should be instantiated in
  15968. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15969. * @returns The parsed texture if successful
  15970. */
  15971. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15972. /**
  15973. * Creates a texture from its base 64 representation.
  15974. * @param data Define the base64 payload without the data: prefix
  15975. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15976. * @param scene Define the scene the texture should belong to
  15977. * @param noMipmap Forces the texture to not create mip map information if true
  15978. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15979. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15980. * @param onLoad define a callback triggered when the texture has been loaded
  15981. * @param onError define a callback triggered when an error occurred during the loading session
  15982. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15983. * @returns the created texture
  15984. */
  15985. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15986. /**
  15987. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15988. * @param data Define the base64 payload without the data: prefix
  15989. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15990. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15991. * @param scene Define the scene the texture should belong to
  15992. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15993. * @param noMipmap Forces the texture to not create mip map information if true
  15994. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15995. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15996. * @param onLoad define a callback triggered when the texture has been loaded
  15997. * @param onError define a callback triggered when an error occurred during the loading session
  15998. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15999. * @returns the created texture
  16000. */
  16001. 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;
  16002. }
  16003. }
  16004. declare module BABYLON {
  16005. /**
  16006. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16007. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16008. */
  16009. export class PostProcessManager {
  16010. private _scene;
  16011. private _indexBuffer;
  16012. private _vertexBuffers;
  16013. /**
  16014. * Creates a new instance PostProcess
  16015. * @param scene The scene that the post process is associated with.
  16016. */
  16017. constructor(scene: Scene);
  16018. private _prepareBuffers;
  16019. private _buildIndexBuffer;
  16020. /**
  16021. * Rebuilds the vertex buffers of the manager.
  16022. * @hidden
  16023. */
  16024. _rebuild(): void;
  16025. /**
  16026. * Prepares a frame to be run through a post process.
  16027. * @param sourceTexture The input texture to the post procesess. (default: null)
  16028. * @param postProcesses An array of post processes to be run. (default: null)
  16029. * @returns True if the post processes were able to be run.
  16030. * @hidden
  16031. */
  16032. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16033. /**
  16034. * Manually render a set of post processes to a texture.
  16035. * @param postProcesses An array of post processes to be run.
  16036. * @param targetTexture The target texture to render to.
  16037. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16038. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16039. * @param lodLevel defines which lod of the texture to render to
  16040. */
  16041. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16042. /**
  16043. * Finalize the result of the output of the postprocesses.
  16044. * @param doNotPresent If true the result will not be displayed to the screen.
  16045. * @param targetTexture The target texture to render to.
  16046. * @param faceIndex The index of the face to bind the target texture to.
  16047. * @param postProcesses The array of post processes to render.
  16048. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16049. * @hidden
  16050. */
  16051. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16052. /**
  16053. * Disposes of the post process manager.
  16054. */
  16055. dispose(): void;
  16056. }
  16057. }
  16058. declare module BABYLON {
  16059. /** Interface used by value gradients (color, factor, ...) */
  16060. export interface IValueGradient {
  16061. /**
  16062. * Gets or sets the gradient value (between 0 and 1)
  16063. */
  16064. gradient: number;
  16065. }
  16066. /** Class used to store color4 gradient */
  16067. export class ColorGradient implements IValueGradient {
  16068. /**
  16069. * Gets or sets the gradient value (between 0 and 1)
  16070. */
  16071. gradient: number;
  16072. /**
  16073. * Gets or sets first associated color
  16074. */
  16075. color1: Color4;
  16076. /**
  16077. * Gets or sets second associated color
  16078. */
  16079. color2?: Color4;
  16080. /**
  16081. * Will get a color picked randomly between color1 and color2.
  16082. * If color2 is undefined then color1 will be used
  16083. * @param result defines the target Color4 to store the result in
  16084. */
  16085. getColorToRef(result: Color4): void;
  16086. }
  16087. /** Class used to store color 3 gradient */
  16088. export class Color3Gradient implements IValueGradient {
  16089. /**
  16090. * Gets or sets the gradient value (between 0 and 1)
  16091. */
  16092. gradient: number;
  16093. /**
  16094. * Gets or sets the associated color
  16095. */
  16096. color: Color3;
  16097. }
  16098. /** Class used to store factor gradient */
  16099. export class FactorGradient implements IValueGradient {
  16100. /**
  16101. * Gets or sets the gradient value (between 0 and 1)
  16102. */
  16103. gradient: number;
  16104. /**
  16105. * Gets or sets first associated factor
  16106. */
  16107. factor1: number;
  16108. /**
  16109. * Gets or sets second associated factor
  16110. */
  16111. factor2?: number;
  16112. /**
  16113. * Will get a number picked randomly between factor1 and factor2.
  16114. * If factor2 is undefined then factor1 will be used
  16115. * @returns the picked number
  16116. */
  16117. getFactor(): number;
  16118. }
  16119. /**
  16120. * Helper used to simplify some generic gradient tasks
  16121. */
  16122. export class GradientHelper {
  16123. /**
  16124. * Gets the current gradient from an array of IValueGradient
  16125. * @param ratio defines the current ratio to get
  16126. * @param gradients defines the array of IValueGradient
  16127. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16128. */
  16129. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16130. }
  16131. }
  16132. declare module BABYLON {
  16133. interface ThinEngine {
  16134. /**
  16135. * Creates a dynamic texture
  16136. * @param width defines the width of the texture
  16137. * @param height defines the height of the texture
  16138. * @param generateMipMaps defines if the engine should generate the mip levels
  16139. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16140. * @returns the dynamic texture inside an InternalTexture
  16141. */
  16142. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16143. /**
  16144. * Update the content of a dynamic texture
  16145. * @param texture defines the texture to update
  16146. * @param canvas defines the canvas containing the source
  16147. * @param invertY defines if data must be stored with Y axis inverted
  16148. * @param premulAlpha defines if alpha is stored as premultiplied
  16149. * @param format defines the format of the data
  16150. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16151. */
  16152. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16153. }
  16154. }
  16155. declare module BABYLON {
  16156. /**
  16157. * A class extending Texture allowing drawing on a texture
  16158. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16159. */
  16160. export class DynamicTexture extends Texture {
  16161. private _generateMipMaps;
  16162. private _canvas;
  16163. private _context;
  16164. private _engine;
  16165. /**
  16166. * Creates a DynamicTexture
  16167. * @param name defines the name of the texture
  16168. * @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
  16169. * @param scene defines the scene where you want the texture
  16170. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16171. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16172. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16173. */
  16174. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16175. /**
  16176. * Get the current class name of the texture useful for serialization or dynamic coding.
  16177. * @returns "DynamicTexture"
  16178. */
  16179. getClassName(): string;
  16180. /**
  16181. * Gets the current state of canRescale
  16182. */
  16183. readonly canRescale: boolean;
  16184. private _recreate;
  16185. /**
  16186. * Scales the texture
  16187. * @param ratio the scale factor to apply to both width and height
  16188. */
  16189. scale(ratio: number): void;
  16190. /**
  16191. * Resizes the texture
  16192. * @param width the new width
  16193. * @param height the new height
  16194. */
  16195. scaleTo(width: number, height: number): void;
  16196. /**
  16197. * Gets the context of the canvas used by the texture
  16198. * @returns the canvas context of the dynamic texture
  16199. */
  16200. getContext(): CanvasRenderingContext2D;
  16201. /**
  16202. * Clears the texture
  16203. */
  16204. clear(): void;
  16205. /**
  16206. * Updates the texture
  16207. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16208. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16209. */
  16210. update(invertY?: boolean, premulAlpha?: boolean): void;
  16211. /**
  16212. * Draws text onto the texture
  16213. * @param text defines the text to be drawn
  16214. * @param x defines the placement of the text from the left
  16215. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16216. * @param font defines the font to be used with font-style, font-size, font-name
  16217. * @param color defines the color used for the text
  16218. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16219. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16220. * @param update defines whether texture is immediately update (default is true)
  16221. */
  16222. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16223. /**
  16224. * Clones the texture
  16225. * @returns the clone of the texture.
  16226. */
  16227. clone(): DynamicTexture;
  16228. /**
  16229. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16230. * @returns a serialized dynamic texture object
  16231. */
  16232. serialize(): any;
  16233. /** @hidden */
  16234. _rebuild(): void;
  16235. }
  16236. }
  16237. declare module BABYLON {
  16238. interface AbstractScene {
  16239. /**
  16240. * The list of procedural textures added to the scene
  16241. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16242. */
  16243. proceduralTextures: Array<ProceduralTexture>;
  16244. }
  16245. /**
  16246. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16247. * in a given scene.
  16248. */
  16249. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16250. /**
  16251. * The component name helpfull to identify the component in the list of scene components.
  16252. */
  16253. readonly name: string;
  16254. /**
  16255. * The scene the component belongs to.
  16256. */
  16257. scene: Scene;
  16258. /**
  16259. * Creates a new instance of the component for the given scene
  16260. * @param scene Defines the scene to register the component in
  16261. */
  16262. constructor(scene: Scene);
  16263. /**
  16264. * Registers the component in a given scene
  16265. */
  16266. register(): void;
  16267. /**
  16268. * Rebuilds the elements related to this component in case of
  16269. * context lost for instance.
  16270. */
  16271. rebuild(): void;
  16272. /**
  16273. * Disposes the component and the associated ressources.
  16274. */
  16275. dispose(): void;
  16276. private _beforeClear;
  16277. }
  16278. }
  16279. declare module BABYLON {
  16280. interface ThinEngine {
  16281. /**
  16282. * Creates a new render target cube texture
  16283. * @param size defines the size of the texture
  16284. * @param options defines the options used to create the texture
  16285. * @returns a new render target cube texture stored in an InternalTexture
  16286. */
  16287. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16288. }
  16289. }
  16290. declare module BABYLON {
  16291. /** @hidden */
  16292. export var proceduralVertexShader: {
  16293. name: string;
  16294. shader: string;
  16295. };
  16296. }
  16297. declare module BABYLON {
  16298. /**
  16299. * 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.
  16300. * This is the base class of any Procedural texture and contains most of the shareable code.
  16301. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16302. */
  16303. export class ProceduralTexture extends Texture {
  16304. isCube: boolean;
  16305. /**
  16306. * Define if the texture is enabled or not (disabled texture will not render)
  16307. */
  16308. isEnabled: boolean;
  16309. /**
  16310. * Define if the texture must be cleared before rendering (default is true)
  16311. */
  16312. autoClear: boolean;
  16313. /**
  16314. * Callback called when the texture is generated
  16315. */
  16316. onGenerated: () => void;
  16317. /**
  16318. * Event raised when the texture is generated
  16319. */
  16320. onGeneratedObservable: Observable<ProceduralTexture>;
  16321. /** @hidden */
  16322. _generateMipMaps: boolean;
  16323. /** @hidden **/
  16324. _effect: Effect;
  16325. /** @hidden */
  16326. _textures: {
  16327. [key: string]: Texture;
  16328. };
  16329. private _size;
  16330. private _currentRefreshId;
  16331. private _refreshRate;
  16332. private _vertexBuffers;
  16333. private _indexBuffer;
  16334. private _uniforms;
  16335. private _samplers;
  16336. private _fragment;
  16337. private _floats;
  16338. private _ints;
  16339. private _floatsArrays;
  16340. private _colors3;
  16341. private _colors4;
  16342. private _vectors2;
  16343. private _vectors3;
  16344. private _matrices;
  16345. private _fallbackTexture;
  16346. private _fallbackTextureUsed;
  16347. private _engine;
  16348. private _cachedDefines;
  16349. private _contentUpdateId;
  16350. private _contentData;
  16351. /**
  16352. * Instantiates a new procedural texture.
  16353. * 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.
  16354. * This is the base class of any Procedural texture and contains most of the shareable code.
  16355. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16356. * @param name Define the name of the texture
  16357. * @param size Define the size of the texture to create
  16358. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16359. * @param scene Define the scene the texture belongs to
  16360. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16361. * @param generateMipMaps Define if the texture should creates mip maps or not
  16362. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16363. */
  16364. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16365. /**
  16366. * The effect that is created when initializing the post process.
  16367. * @returns The created effect corresponding the the postprocess.
  16368. */
  16369. getEffect(): Effect;
  16370. /**
  16371. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16372. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16373. */
  16374. getContent(): Nullable<ArrayBufferView>;
  16375. private _createIndexBuffer;
  16376. /** @hidden */
  16377. _rebuild(): void;
  16378. /**
  16379. * Resets the texture in order to recreate its associated resources.
  16380. * This can be called in case of context loss
  16381. */
  16382. reset(): void;
  16383. protected _getDefines(): string;
  16384. /**
  16385. * Is the texture ready to be used ? (rendered at least once)
  16386. * @returns true if ready, otherwise, false.
  16387. */
  16388. isReady(): boolean;
  16389. /**
  16390. * Resets the refresh counter of the texture and start bak from scratch.
  16391. * Could be useful to regenerate the texture if it is setup to render only once.
  16392. */
  16393. resetRefreshCounter(): void;
  16394. /**
  16395. * Set the fragment shader to use in order to render the texture.
  16396. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16397. */
  16398. setFragment(fragment: any): void;
  16399. /**
  16400. * Define the refresh rate of the texture or the rendering frequency.
  16401. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16402. */
  16403. refreshRate: number;
  16404. /** @hidden */
  16405. _shouldRender(): boolean;
  16406. /**
  16407. * Get the size the texture is rendering at.
  16408. * @returns the size (texture is always squared)
  16409. */
  16410. getRenderSize(): number;
  16411. /**
  16412. * Resize the texture to new value.
  16413. * @param size Define the new size the texture should have
  16414. * @param generateMipMaps Define whether the new texture should create mip maps
  16415. */
  16416. resize(size: number, generateMipMaps: boolean): void;
  16417. private _checkUniform;
  16418. /**
  16419. * Set a texture in the shader program used to render.
  16420. * @param name Define the name of the uniform samplers as defined in the shader
  16421. * @param texture Define the texture to bind to this sampler
  16422. * @return the texture itself allowing "fluent" like uniform updates
  16423. */
  16424. setTexture(name: string, texture: Texture): ProceduralTexture;
  16425. /**
  16426. * Set a float in the shader.
  16427. * @param name Define the name of the uniform as defined in the shader
  16428. * @param value Define the value to give to the uniform
  16429. * @return the texture itself allowing "fluent" like uniform updates
  16430. */
  16431. setFloat(name: string, value: number): ProceduralTexture;
  16432. /**
  16433. * Set a int in the shader.
  16434. * @param name Define the name of the uniform as defined in the shader
  16435. * @param value Define the value to give to the uniform
  16436. * @return the texture itself allowing "fluent" like uniform updates
  16437. */
  16438. setInt(name: string, value: number): ProceduralTexture;
  16439. /**
  16440. * Set an array of floats in the shader.
  16441. * @param name Define the name of the uniform as defined in the shader
  16442. * @param value Define the value to give to the uniform
  16443. * @return the texture itself allowing "fluent" like uniform updates
  16444. */
  16445. setFloats(name: string, value: number[]): ProceduralTexture;
  16446. /**
  16447. * Set a vec3 in the shader from a Color3.
  16448. * @param name Define the name of the uniform as defined in the shader
  16449. * @param value Define the value to give to the uniform
  16450. * @return the texture itself allowing "fluent" like uniform updates
  16451. */
  16452. setColor3(name: string, value: Color3): ProceduralTexture;
  16453. /**
  16454. * Set a vec4 in the shader from a Color4.
  16455. * @param name Define the name of the uniform as defined in the shader
  16456. * @param value Define the value to give to the uniform
  16457. * @return the texture itself allowing "fluent" like uniform updates
  16458. */
  16459. setColor4(name: string, value: Color4): ProceduralTexture;
  16460. /**
  16461. * Set a vec2 in the shader from a Vector2.
  16462. * @param name Define the name of the uniform as defined in the shader
  16463. * @param value Define the value to give to the uniform
  16464. * @return the texture itself allowing "fluent" like uniform updates
  16465. */
  16466. setVector2(name: string, value: Vector2): ProceduralTexture;
  16467. /**
  16468. * Set a vec3 in the shader from a Vector3.
  16469. * @param name Define the name of the uniform as defined in the shader
  16470. * @param value Define the value to give to the uniform
  16471. * @return the texture itself allowing "fluent" like uniform updates
  16472. */
  16473. setVector3(name: string, value: Vector3): ProceduralTexture;
  16474. /**
  16475. * Set a mat4 in the shader from a MAtrix.
  16476. * @param name Define the name of the uniform as defined in the shader
  16477. * @param value Define the value to give to the uniform
  16478. * @return the texture itself allowing "fluent" like uniform updates
  16479. */
  16480. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16481. /**
  16482. * Render the texture to its associated render target.
  16483. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16484. */
  16485. render(useCameraPostProcess?: boolean): void;
  16486. /**
  16487. * Clone the texture.
  16488. * @returns the cloned texture
  16489. */
  16490. clone(): ProceduralTexture;
  16491. /**
  16492. * Dispose the texture and release its asoociated resources.
  16493. */
  16494. dispose(): void;
  16495. }
  16496. }
  16497. declare module BABYLON {
  16498. /**
  16499. * This represents the base class for particle system in Babylon.
  16500. * 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.
  16501. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16502. * @example https://doc.babylonjs.com/babylon101/particles
  16503. */
  16504. export class BaseParticleSystem {
  16505. /**
  16506. * Source color is added to the destination color without alpha affecting the result
  16507. */
  16508. static BLENDMODE_ONEONE: number;
  16509. /**
  16510. * Blend current color and particle color using particle’s alpha
  16511. */
  16512. static BLENDMODE_STANDARD: number;
  16513. /**
  16514. * Add current color and particle color multiplied by particle’s alpha
  16515. */
  16516. static BLENDMODE_ADD: number;
  16517. /**
  16518. * Multiply current color with particle color
  16519. */
  16520. static BLENDMODE_MULTIPLY: number;
  16521. /**
  16522. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16523. */
  16524. static BLENDMODE_MULTIPLYADD: number;
  16525. /**
  16526. * List of animations used by the particle system.
  16527. */
  16528. animations: Animation[];
  16529. /**
  16530. * The id of the Particle system.
  16531. */
  16532. id: string;
  16533. /**
  16534. * The friendly name of the Particle system.
  16535. */
  16536. name: string;
  16537. /**
  16538. * The rendering group used by the Particle system to chose when to render.
  16539. */
  16540. renderingGroupId: number;
  16541. /**
  16542. * The emitter represents the Mesh or position we are attaching the particle system to.
  16543. */
  16544. emitter: Nullable<AbstractMesh | Vector3>;
  16545. /**
  16546. * The maximum number of particles to emit per frame
  16547. */
  16548. emitRate: number;
  16549. /**
  16550. * If you want to launch only a few particles at once, that can be done, as well.
  16551. */
  16552. manualEmitCount: number;
  16553. /**
  16554. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16555. */
  16556. updateSpeed: number;
  16557. /**
  16558. * The amount of time the particle system is running (depends of the overall update speed).
  16559. */
  16560. targetStopDuration: number;
  16561. /**
  16562. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16563. */
  16564. disposeOnStop: boolean;
  16565. /**
  16566. * Minimum power of emitting particles.
  16567. */
  16568. minEmitPower: number;
  16569. /**
  16570. * Maximum power of emitting particles.
  16571. */
  16572. maxEmitPower: number;
  16573. /**
  16574. * Minimum life time of emitting particles.
  16575. */
  16576. minLifeTime: number;
  16577. /**
  16578. * Maximum life time of emitting particles.
  16579. */
  16580. maxLifeTime: number;
  16581. /**
  16582. * Minimum Size of emitting particles.
  16583. */
  16584. minSize: number;
  16585. /**
  16586. * Maximum Size of emitting particles.
  16587. */
  16588. maxSize: number;
  16589. /**
  16590. * Minimum scale of emitting particles on X axis.
  16591. */
  16592. minScaleX: number;
  16593. /**
  16594. * Maximum scale of emitting particles on X axis.
  16595. */
  16596. maxScaleX: number;
  16597. /**
  16598. * Minimum scale of emitting particles on Y axis.
  16599. */
  16600. minScaleY: number;
  16601. /**
  16602. * Maximum scale of emitting particles on Y axis.
  16603. */
  16604. maxScaleY: number;
  16605. /**
  16606. * Gets or sets the minimal initial rotation in radians.
  16607. */
  16608. minInitialRotation: number;
  16609. /**
  16610. * Gets or sets the maximal initial rotation in radians.
  16611. */
  16612. maxInitialRotation: number;
  16613. /**
  16614. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16615. */
  16616. minAngularSpeed: number;
  16617. /**
  16618. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16619. */
  16620. maxAngularSpeed: number;
  16621. /**
  16622. * The texture used to render each particle. (this can be a spritesheet)
  16623. */
  16624. particleTexture: Nullable<Texture>;
  16625. /**
  16626. * The layer mask we are rendering the particles through.
  16627. */
  16628. layerMask: number;
  16629. /**
  16630. * This can help using your own shader to render the particle system.
  16631. * The according effect will be created
  16632. */
  16633. customShader: any;
  16634. /**
  16635. * By default particle system starts as soon as they are created. This prevents the
  16636. * automatic start to happen and let you decide when to start emitting particles.
  16637. */
  16638. preventAutoStart: boolean;
  16639. private _noiseTexture;
  16640. /**
  16641. * Gets or sets a texture used to add random noise to particle positions
  16642. */
  16643. noiseTexture: Nullable<ProceduralTexture>;
  16644. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16645. noiseStrength: Vector3;
  16646. /**
  16647. * Callback triggered when the particle animation is ending.
  16648. */
  16649. onAnimationEnd: Nullable<() => void>;
  16650. /**
  16651. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16652. */
  16653. blendMode: number;
  16654. /**
  16655. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16656. * to override the particles.
  16657. */
  16658. forceDepthWrite: boolean;
  16659. /** 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 */
  16660. preWarmCycles: number;
  16661. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16662. preWarmStepOffset: number;
  16663. /**
  16664. * 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)
  16665. */
  16666. spriteCellChangeSpeed: number;
  16667. /**
  16668. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16669. */
  16670. startSpriteCellID: number;
  16671. /**
  16672. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16673. */
  16674. endSpriteCellID: number;
  16675. /**
  16676. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16677. */
  16678. spriteCellWidth: number;
  16679. /**
  16680. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16681. */
  16682. spriteCellHeight: number;
  16683. /**
  16684. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16685. */
  16686. spriteRandomStartCell: boolean;
  16687. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16688. translationPivot: Vector2;
  16689. /** @hidden */
  16690. protected _isAnimationSheetEnabled: boolean;
  16691. /**
  16692. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16693. */
  16694. beginAnimationOnStart: boolean;
  16695. /**
  16696. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16697. */
  16698. beginAnimationFrom: number;
  16699. /**
  16700. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16701. */
  16702. beginAnimationTo: number;
  16703. /**
  16704. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16705. */
  16706. beginAnimationLoop: boolean;
  16707. /**
  16708. * Gets or sets a world offset applied to all particles
  16709. */
  16710. worldOffset: Vector3;
  16711. /**
  16712. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16713. */
  16714. isAnimationSheetEnabled: boolean;
  16715. /**
  16716. * Get hosting scene
  16717. * @returns the scene
  16718. */
  16719. getScene(): Scene;
  16720. /**
  16721. * You can use gravity if you want to give an orientation to your particles.
  16722. */
  16723. gravity: Vector3;
  16724. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16725. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16726. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16727. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16728. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16729. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16730. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16731. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16732. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16733. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16734. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16735. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16736. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16737. /**
  16738. * Defines the delay in milliseconds before starting the system (0 by default)
  16739. */
  16740. startDelay: number;
  16741. /**
  16742. * Gets the current list of drag gradients.
  16743. * You must use addDragGradient and removeDragGradient to udpate this list
  16744. * @returns the list of drag gradients
  16745. */
  16746. getDragGradients(): Nullable<Array<FactorGradient>>;
  16747. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16748. limitVelocityDamping: number;
  16749. /**
  16750. * Gets the current list of limit velocity gradients.
  16751. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16752. * @returns the list of limit velocity gradients
  16753. */
  16754. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16755. /**
  16756. * Gets the current list of color gradients.
  16757. * You must use addColorGradient and removeColorGradient to udpate this list
  16758. * @returns the list of color gradients
  16759. */
  16760. getColorGradients(): Nullable<Array<ColorGradient>>;
  16761. /**
  16762. * Gets the current list of size gradients.
  16763. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16764. * @returns the list of size gradients
  16765. */
  16766. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16767. /**
  16768. * Gets the current list of color remap gradients.
  16769. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16770. * @returns the list of color remap gradients
  16771. */
  16772. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16773. /**
  16774. * Gets the current list of alpha remap gradients.
  16775. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16776. * @returns the list of alpha remap gradients
  16777. */
  16778. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16779. /**
  16780. * Gets the current list of life time gradients.
  16781. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16782. * @returns the list of life time gradients
  16783. */
  16784. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16785. /**
  16786. * Gets the current list of angular speed gradients.
  16787. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16788. * @returns the list of angular speed gradients
  16789. */
  16790. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16791. /**
  16792. * Gets the current list of velocity gradients.
  16793. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16794. * @returns the list of velocity gradients
  16795. */
  16796. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16797. /**
  16798. * Gets the current list of start size gradients.
  16799. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16800. * @returns the list of start size gradients
  16801. */
  16802. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16803. /**
  16804. * Gets the current list of emit rate gradients.
  16805. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16806. * @returns the list of emit rate gradients
  16807. */
  16808. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16809. /**
  16810. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16811. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16812. */
  16813. direction1: Vector3;
  16814. /**
  16815. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16816. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16817. */
  16818. direction2: Vector3;
  16819. /**
  16820. * 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.
  16821. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16822. */
  16823. minEmitBox: Vector3;
  16824. /**
  16825. * 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.
  16826. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16827. */
  16828. maxEmitBox: Vector3;
  16829. /**
  16830. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16831. */
  16832. color1: Color4;
  16833. /**
  16834. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16835. */
  16836. color2: Color4;
  16837. /**
  16838. * Color the particle will have at the end of its lifetime
  16839. */
  16840. colorDead: Color4;
  16841. /**
  16842. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16843. */
  16844. textureMask: Color4;
  16845. /**
  16846. * The particle emitter type defines the emitter used by the particle system.
  16847. * It can be for example box, sphere, or cone...
  16848. */
  16849. particleEmitterType: IParticleEmitterType;
  16850. /** @hidden */
  16851. _isSubEmitter: boolean;
  16852. /**
  16853. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16854. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16855. */
  16856. billboardMode: number;
  16857. protected _isBillboardBased: boolean;
  16858. /**
  16859. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16860. */
  16861. isBillboardBased: boolean;
  16862. /**
  16863. * The scene the particle system belongs to.
  16864. */
  16865. protected _scene: Scene;
  16866. /**
  16867. * Local cache of defines for image processing.
  16868. */
  16869. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16870. /**
  16871. * Default configuration related to image processing available in the standard Material.
  16872. */
  16873. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16874. /**
  16875. * Gets the image processing configuration used either in this material.
  16876. */
  16877. /**
  16878. * Sets the Default image processing configuration used either in the this material.
  16879. *
  16880. * If sets to null, the scene one is in use.
  16881. */
  16882. imageProcessingConfiguration: ImageProcessingConfiguration;
  16883. /**
  16884. * Attaches a new image processing configuration to the Standard Material.
  16885. * @param configuration
  16886. */
  16887. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16888. /** @hidden */
  16889. protected _reset(): void;
  16890. /** @hidden */
  16891. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16892. /**
  16893. * Instantiates a particle system.
  16894. * 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.
  16895. * @param name The name of the particle system
  16896. */
  16897. constructor(name: string);
  16898. /**
  16899. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16900. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16901. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16902. * @returns the emitter
  16903. */
  16904. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16905. /**
  16906. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16907. * @param radius The radius of the hemisphere to emit from
  16908. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16909. * @returns the emitter
  16910. */
  16911. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16912. /**
  16913. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16914. * @param radius The radius of the sphere to emit from
  16915. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16916. * @returns the emitter
  16917. */
  16918. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16919. /**
  16920. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16921. * @param radius The radius of the sphere to emit from
  16922. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16923. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16924. * @returns the emitter
  16925. */
  16926. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16927. /**
  16928. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16929. * @param radius The radius of the emission cylinder
  16930. * @param height The height of the emission cylinder
  16931. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16932. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16933. * @returns the emitter
  16934. */
  16935. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16936. /**
  16937. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16938. * @param radius The radius of the cylinder to emit from
  16939. * @param height The height of the emission cylinder
  16940. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16941. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16942. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16943. * @returns the emitter
  16944. */
  16945. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16946. /**
  16947. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16948. * @param radius The radius of the cone to emit from
  16949. * @param angle The base angle of the cone
  16950. * @returns the emitter
  16951. */
  16952. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16953. /**
  16954. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16955. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16956. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16957. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16958. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16959. * @returns the emitter
  16960. */
  16961. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16962. }
  16963. }
  16964. declare module BABYLON {
  16965. /**
  16966. * Type of sub emitter
  16967. */
  16968. export enum SubEmitterType {
  16969. /**
  16970. * Attached to the particle over it's lifetime
  16971. */
  16972. ATTACHED = 0,
  16973. /**
  16974. * Created when the particle dies
  16975. */
  16976. END = 1
  16977. }
  16978. /**
  16979. * Sub emitter class used to emit particles from an existing particle
  16980. */
  16981. export class SubEmitter {
  16982. /**
  16983. * the particle system to be used by the sub emitter
  16984. */
  16985. particleSystem: ParticleSystem;
  16986. /**
  16987. * Type of the submitter (Default: END)
  16988. */
  16989. type: SubEmitterType;
  16990. /**
  16991. * 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)
  16992. * Note: This only is supported when using an emitter of type Mesh
  16993. */
  16994. inheritDirection: boolean;
  16995. /**
  16996. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16997. */
  16998. inheritedVelocityAmount: number;
  16999. /**
  17000. * Creates a sub emitter
  17001. * @param particleSystem the particle system to be used by the sub emitter
  17002. */
  17003. constructor(
  17004. /**
  17005. * the particle system to be used by the sub emitter
  17006. */
  17007. particleSystem: ParticleSystem);
  17008. /**
  17009. * Clones the sub emitter
  17010. * @returns the cloned sub emitter
  17011. */
  17012. clone(): SubEmitter;
  17013. /**
  17014. * Serialize current object to a JSON object
  17015. * @returns the serialized object
  17016. */
  17017. serialize(): any;
  17018. /** @hidden */
  17019. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17020. /**
  17021. * Creates a new SubEmitter from a serialized JSON version
  17022. * @param serializationObject defines the JSON object to read from
  17023. * @param scene defines the hosting scene
  17024. * @param rootUrl defines the rootUrl for data loading
  17025. * @returns a new SubEmitter
  17026. */
  17027. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17028. /** Release associated resources */
  17029. dispose(): void;
  17030. }
  17031. }
  17032. declare module BABYLON {
  17033. /** @hidden */
  17034. export var clipPlaneFragmentDeclaration: {
  17035. name: string;
  17036. shader: string;
  17037. };
  17038. }
  17039. declare module BABYLON {
  17040. /** @hidden */
  17041. export var imageProcessingDeclaration: {
  17042. name: string;
  17043. shader: string;
  17044. };
  17045. }
  17046. declare module BABYLON {
  17047. /** @hidden */
  17048. export var imageProcessingFunctions: {
  17049. name: string;
  17050. shader: string;
  17051. };
  17052. }
  17053. declare module BABYLON {
  17054. /** @hidden */
  17055. export var clipPlaneFragment: {
  17056. name: string;
  17057. shader: string;
  17058. };
  17059. }
  17060. declare module BABYLON {
  17061. /** @hidden */
  17062. export var particlesPixelShader: {
  17063. name: string;
  17064. shader: string;
  17065. };
  17066. }
  17067. declare module BABYLON {
  17068. /** @hidden */
  17069. export var clipPlaneVertexDeclaration: {
  17070. name: string;
  17071. shader: string;
  17072. };
  17073. }
  17074. declare module BABYLON {
  17075. /** @hidden */
  17076. export var clipPlaneVertex: {
  17077. name: string;
  17078. shader: string;
  17079. };
  17080. }
  17081. declare module BABYLON {
  17082. /** @hidden */
  17083. export var particlesVertexShader: {
  17084. name: string;
  17085. shader: string;
  17086. };
  17087. }
  17088. declare module BABYLON {
  17089. /**
  17090. * This represents a particle system in Babylon.
  17091. * 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.
  17092. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17093. * @example https://doc.babylonjs.com/babylon101/particles
  17094. */
  17095. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17096. /**
  17097. * Billboard mode will only apply to Y axis
  17098. */
  17099. static readonly BILLBOARDMODE_Y: number;
  17100. /**
  17101. * Billboard mode will apply to all axes
  17102. */
  17103. static readonly BILLBOARDMODE_ALL: number;
  17104. /**
  17105. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17106. */
  17107. static readonly BILLBOARDMODE_STRETCHED: number;
  17108. /**
  17109. * This function can be defined to provide custom update for active particles.
  17110. * This function will be called instead of regular update (age, position, color, etc.).
  17111. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17112. */
  17113. updateFunction: (particles: Particle[]) => void;
  17114. private _emitterWorldMatrix;
  17115. /**
  17116. * This function can be defined to specify initial direction for every new particle.
  17117. * It by default use the emitterType defined function
  17118. */
  17119. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17120. /**
  17121. * This function can be defined to specify initial position for every new particle.
  17122. * It by default use the emitterType defined function
  17123. */
  17124. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17125. /**
  17126. * @hidden
  17127. */
  17128. _inheritedVelocityOffset: Vector3;
  17129. /**
  17130. * An event triggered when the system is disposed
  17131. */
  17132. onDisposeObservable: Observable<ParticleSystem>;
  17133. private _onDisposeObserver;
  17134. /**
  17135. * Sets a callback that will be triggered when the system is disposed
  17136. */
  17137. onDispose: () => void;
  17138. private _particles;
  17139. private _epsilon;
  17140. private _capacity;
  17141. private _stockParticles;
  17142. private _newPartsExcess;
  17143. private _vertexData;
  17144. private _vertexBuffer;
  17145. private _vertexBuffers;
  17146. private _spriteBuffer;
  17147. private _indexBuffer;
  17148. private _effect;
  17149. private _customEffect;
  17150. private _cachedDefines;
  17151. private _scaledColorStep;
  17152. private _colorDiff;
  17153. private _scaledDirection;
  17154. private _scaledGravity;
  17155. private _currentRenderId;
  17156. private _alive;
  17157. private _useInstancing;
  17158. private _started;
  17159. private _stopped;
  17160. private _actualFrame;
  17161. private _scaledUpdateSpeed;
  17162. private _vertexBufferSize;
  17163. /** @hidden */
  17164. _currentEmitRateGradient: Nullable<FactorGradient>;
  17165. /** @hidden */
  17166. _currentEmitRate1: number;
  17167. /** @hidden */
  17168. _currentEmitRate2: number;
  17169. /** @hidden */
  17170. _currentStartSizeGradient: Nullable<FactorGradient>;
  17171. /** @hidden */
  17172. _currentStartSize1: number;
  17173. /** @hidden */
  17174. _currentStartSize2: number;
  17175. private readonly _rawTextureWidth;
  17176. private _rampGradientsTexture;
  17177. private _useRampGradients;
  17178. /** Gets or sets a boolean indicating that ramp gradients must be used
  17179. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17180. */
  17181. useRampGradients: boolean;
  17182. /**
  17183. * 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.
  17184. * 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: [])
  17185. */
  17186. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17187. private _subEmitters;
  17188. /**
  17189. * @hidden
  17190. * If the particle systems emitter should be disposed when the particle system is disposed
  17191. */
  17192. _disposeEmitterOnDispose: boolean;
  17193. /**
  17194. * The current active Sub-systems, this property is used by the root particle system only.
  17195. */
  17196. activeSubSystems: Array<ParticleSystem>;
  17197. private _rootParticleSystem;
  17198. /**
  17199. * Gets the current list of active particles
  17200. */
  17201. readonly particles: Particle[];
  17202. /**
  17203. * Returns the string "ParticleSystem"
  17204. * @returns a string containing the class name
  17205. */
  17206. getClassName(): string;
  17207. /**
  17208. * Instantiates a particle system.
  17209. * 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.
  17210. * @param name The name of the particle system
  17211. * @param capacity The max number of particles alive at the same time
  17212. * @param scene The scene the particle system belongs to
  17213. * @param customEffect a custom effect used to change the way particles are rendered by default
  17214. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17215. * @param epsilon Offset used to render the particles
  17216. */
  17217. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17218. private _addFactorGradient;
  17219. private _removeFactorGradient;
  17220. /**
  17221. * Adds a new life time gradient
  17222. * @param gradient defines the gradient to use (between 0 and 1)
  17223. * @param factor defines the life time factor to affect to the specified gradient
  17224. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17225. * @returns the current particle system
  17226. */
  17227. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17228. /**
  17229. * Remove a specific life time gradient
  17230. * @param gradient defines the gradient to remove
  17231. * @returns the current particle system
  17232. */
  17233. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17234. /**
  17235. * Adds a new size gradient
  17236. * @param gradient defines the gradient to use (between 0 and 1)
  17237. * @param factor defines the size factor to affect to the specified gradient
  17238. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17239. * @returns the current particle system
  17240. */
  17241. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17242. /**
  17243. * Remove a specific size gradient
  17244. * @param gradient defines the gradient to remove
  17245. * @returns the current particle system
  17246. */
  17247. removeSizeGradient(gradient: number): IParticleSystem;
  17248. /**
  17249. * Adds a new color remap gradient
  17250. * @param gradient defines the gradient to use (between 0 and 1)
  17251. * @param min defines the color remap minimal range
  17252. * @param max defines the color remap maximal range
  17253. * @returns the current particle system
  17254. */
  17255. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17256. /**
  17257. * Remove a specific color remap gradient
  17258. * @param gradient defines the gradient to remove
  17259. * @returns the current particle system
  17260. */
  17261. removeColorRemapGradient(gradient: number): IParticleSystem;
  17262. /**
  17263. * Adds a new alpha remap gradient
  17264. * @param gradient defines the gradient to use (between 0 and 1)
  17265. * @param min defines the alpha remap minimal range
  17266. * @param max defines the alpha remap maximal range
  17267. * @returns the current particle system
  17268. */
  17269. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17270. /**
  17271. * Remove a specific alpha remap gradient
  17272. * @param gradient defines the gradient to remove
  17273. * @returns the current particle system
  17274. */
  17275. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17276. /**
  17277. * Adds a new angular speed gradient
  17278. * @param gradient defines the gradient to use (between 0 and 1)
  17279. * @param factor defines the angular speed to affect to the specified gradient
  17280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17281. * @returns the current particle system
  17282. */
  17283. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17284. /**
  17285. * Remove a specific angular speed gradient
  17286. * @param gradient defines the gradient to remove
  17287. * @returns the current particle system
  17288. */
  17289. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17290. /**
  17291. * Adds a new velocity gradient
  17292. * @param gradient defines the gradient to use (between 0 and 1)
  17293. * @param factor defines the velocity to affect to the specified gradient
  17294. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17295. * @returns the current particle system
  17296. */
  17297. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17298. /**
  17299. * Remove a specific velocity gradient
  17300. * @param gradient defines the gradient to remove
  17301. * @returns the current particle system
  17302. */
  17303. removeVelocityGradient(gradient: number): IParticleSystem;
  17304. /**
  17305. * Adds a new limit velocity gradient
  17306. * @param gradient defines the gradient to use (between 0 and 1)
  17307. * @param factor defines the limit velocity value to affect to the specified gradient
  17308. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17309. * @returns the current particle system
  17310. */
  17311. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17312. /**
  17313. * Remove a specific limit velocity gradient
  17314. * @param gradient defines the gradient to remove
  17315. * @returns the current particle system
  17316. */
  17317. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17318. /**
  17319. * Adds a new drag gradient
  17320. * @param gradient defines the gradient to use (between 0 and 1)
  17321. * @param factor defines the drag value to affect to the specified gradient
  17322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17323. * @returns the current particle system
  17324. */
  17325. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17326. /**
  17327. * Remove a specific drag gradient
  17328. * @param gradient defines the gradient to remove
  17329. * @returns the current particle system
  17330. */
  17331. removeDragGradient(gradient: number): IParticleSystem;
  17332. /**
  17333. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17334. * @param gradient defines the gradient to use (between 0 and 1)
  17335. * @param factor defines the emit rate value to affect to the specified gradient
  17336. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17337. * @returns the current particle system
  17338. */
  17339. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17340. /**
  17341. * Remove a specific emit rate gradient
  17342. * @param gradient defines the gradient to remove
  17343. * @returns the current particle system
  17344. */
  17345. removeEmitRateGradient(gradient: number): IParticleSystem;
  17346. /**
  17347. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17348. * @param gradient defines the gradient to use (between 0 and 1)
  17349. * @param factor defines the start size value to affect to the specified gradient
  17350. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17351. * @returns the current particle system
  17352. */
  17353. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17354. /**
  17355. * Remove a specific start size gradient
  17356. * @param gradient defines the gradient to remove
  17357. * @returns the current particle system
  17358. */
  17359. removeStartSizeGradient(gradient: number): IParticleSystem;
  17360. private _createRampGradientTexture;
  17361. /**
  17362. * Gets the current list of ramp gradients.
  17363. * You must use addRampGradient and removeRampGradient to udpate this list
  17364. * @returns the list of ramp gradients
  17365. */
  17366. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17367. /**
  17368. * Adds a new ramp gradient used to remap particle colors
  17369. * @param gradient defines the gradient to use (between 0 and 1)
  17370. * @param color defines the color to affect to the specified gradient
  17371. * @returns the current particle system
  17372. */
  17373. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17374. /**
  17375. * Remove a specific ramp gradient
  17376. * @param gradient defines the gradient to remove
  17377. * @returns the current particle system
  17378. */
  17379. removeRampGradient(gradient: number): ParticleSystem;
  17380. /**
  17381. * Adds a new color gradient
  17382. * @param gradient defines the gradient to use (between 0 and 1)
  17383. * @param color1 defines the color to affect to the specified gradient
  17384. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17385. * @returns this particle system
  17386. */
  17387. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17388. /**
  17389. * Remove a specific color gradient
  17390. * @param gradient defines the gradient to remove
  17391. * @returns this particle system
  17392. */
  17393. removeColorGradient(gradient: number): IParticleSystem;
  17394. private _fetchR;
  17395. protected _reset(): void;
  17396. private _resetEffect;
  17397. private _createVertexBuffers;
  17398. private _createIndexBuffer;
  17399. /**
  17400. * Gets the maximum number of particles active at the same time.
  17401. * @returns The max number of active particles.
  17402. */
  17403. getCapacity(): number;
  17404. /**
  17405. * Gets whether there are still active particles in the system.
  17406. * @returns True if it is alive, otherwise false.
  17407. */
  17408. isAlive(): boolean;
  17409. /**
  17410. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17411. * @returns True if it has been started, otherwise false.
  17412. */
  17413. isStarted(): boolean;
  17414. private _prepareSubEmitterInternalArray;
  17415. /**
  17416. * Starts the particle system and begins to emit
  17417. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17418. */
  17419. start(delay?: number): void;
  17420. /**
  17421. * Stops the particle system.
  17422. * @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.
  17423. */
  17424. stop(stopSubEmitters?: boolean): void;
  17425. /**
  17426. * Remove all active particles
  17427. */
  17428. reset(): void;
  17429. /**
  17430. * @hidden (for internal use only)
  17431. */
  17432. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17433. /**
  17434. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17435. * Its lifetime will start back at 0.
  17436. */
  17437. recycleParticle: (particle: Particle) => void;
  17438. private _stopSubEmitters;
  17439. private _createParticle;
  17440. private _removeFromRoot;
  17441. private _emitFromParticle;
  17442. private _update;
  17443. /** @hidden */
  17444. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17445. /** @hidden */
  17446. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17447. /** @hidden */
  17448. private _getEffect;
  17449. /**
  17450. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17451. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17452. */
  17453. animate(preWarmOnly?: boolean): void;
  17454. private _appendParticleVertices;
  17455. /**
  17456. * Rebuilds the particle system.
  17457. */
  17458. rebuild(): void;
  17459. /**
  17460. * Is this system ready to be used/rendered
  17461. * @return true if the system is ready
  17462. */
  17463. isReady(): boolean;
  17464. private _render;
  17465. /**
  17466. * Renders the particle system in its current state.
  17467. * @returns the current number of particles
  17468. */
  17469. render(): number;
  17470. /**
  17471. * Disposes the particle system and free the associated resources
  17472. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17473. */
  17474. dispose(disposeTexture?: boolean): void;
  17475. /**
  17476. * Clones the particle system.
  17477. * @param name The name of the cloned object
  17478. * @param newEmitter The new emitter to use
  17479. * @returns the cloned particle system
  17480. */
  17481. clone(name: string, newEmitter: any): ParticleSystem;
  17482. /**
  17483. * Serializes the particle system to a JSON object.
  17484. * @returns the JSON object
  17485. */
  17486. serialize(): any;
  17487. /** @hidden */
  17488. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17489. /** @hidden */
  17490. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17491. /**
  17492. * Parses a JSON object to create a particle system.
  17493. * @param parsedParticleSystem The JSON object to parse
  17494. * @param scene The scene to create the particle system in
  17495. * @param rootUrl The root url to use to load external dependencies like texture
  17496. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17497. * @returns the Parsed particle system
  17498. */
  17499. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17500. }
  17501. }
  17502. declare module BABYLON {
  17503. /**
  17504. * A particle represents one of the element emitted by a particle system.
  17505. * This is mainly define by its coordinates, direction, velocity and age.
  17506. */
  17507. export class Particle {
  17508. /**
  17509. * The particle system the particle belongs to.
  17510. */
  17511. particleSystem: ParticleSystem;
  17512. private static _Count;
  17513. /**
  17514. * Unique ID of the particle
  17515. */
  17516. id: number;
  17517. /**
  17518. * The world position of the particle in the scene.
  17519. */
  17520. position: Vector3;
  17521. /**
  17522. * The world direction of the particle in the scene.
  17523. */
  17524. direction: Vector3;
  17525. /**
  17526. * The color of the particle.
  17527. */
  17528. color: Color4;
  17529. /**
  17530. * The color change of the particle per step.
  17531. */
  17532. colorStep: Color4;
  17533. /**
  17534. * Defines how long will the life of the particle be.
  17535. */
  17536. lifeTime: number;
  17537. /**
  17538. * The current age of the particle.
  17539. */
  17540. age: number;
  17541. /**
  17542. * The current size of the particle.
  17543. */
  17544. size: number;
  17545. /**
  17546. * The current scale of the particle.
  17547. */
  17548. scale: Vector2;
  17549. /**
  17550. * The current angle of the particle.
  17551. */
  17552. angle: number;
  17553. /**
  17554. * Defines how fast is the angle changing.
  17555. */
  17556. angularSpeed: number;
  17557. /**
  17558. * Defines the cell index used by the particle to be rendered from a sprite.
  17559. */
  17560. cellIndex: number;
  17561. /**
  17562. * The information required to support color remapping
  17563. */
  17564. remapData: Vector4;
  17565. /** @hidden */
  17566. _randomCellOffset?: number;
  17567. /** @hidden */
  17568. _initialDirection: Nullable<Vector3>;
  17569. /** @hidden */
  17570. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17571. /** @hidden */
  17572. _initialStartSpriteCellID: number;
  17573. /** @hidden */
  17574. _initialEndSpriteCellID: number;
  17575. /** @hidden */
  17576. _currentColorGradient: Nullable<ColorGradient>;
  17577. /** @hidden */
  17578. _currentColor1: Color4;
  17579. /** @hidden */
  17580. _currentColor2: Color4;
  17581. /** @hidden */
  17582. _currentSizeGradient: Nullable<FactorGradient>;
  17583. /** @hidden */
  17584. _currentSize1: number;
  17585. /** @hidden */
  17586. _currentSize2: number;
  17587. /** @hidden */
  17588. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17589. /** @hidden */
  17590. _currentAngularSpeed1: number;
  17591. /** @hidden */
  17592. _currentAngularSpeed2: number;
  17593. /** @hidden */
  17594. _currentVelocityGradient: Nullable<FactorGradient>;
  17595. /** @hidden */
  17596. _currentVelocity1: number;
  17597. /** @hidden */
  17598. _currentVelocity2: number;
  17599. /** @hidden */
  17600. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17601. /** @hidden */
  17602. _currentLimitVelocity1: number;
  17603. /** @hidden */
  17604. _currentLimitVelocity2: number;
  17605. /** @hidden */
  17606. _currentDragGradient: Nullable<FactorGradient>;
  17607. /** @hidden */
  17608. _currentDrag1: number;
  17609. /** @hidden */
  17610. _currentDrag2: number;
  17611. /** @hidden */
  17612. _randomNoiseCoordinates1: Vector3;
  17613. /** @hidden */
  17614. _randomNoiseCoordinates2: Vector3;
  17615. /**
  17616. * Creates a new instance Particle
  17617. * @param particleSystem the particle system the particle belongs to
  17618. */
  17619. constructor(
  17620. /**
  17621. * The particle system the particle belongs to.
  17622. */
  17623. particleSystem: ParticleSystem);
  17624. private updateCellInfoFromSystem;
  17625. /**
  17626. * Defines how the sprite cell index is updated for the particle
  17627. */
  17628. updateCellIndex(): void;
  17629. /** @hidden */
  17630. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17631. /** @hidden */
  17632. _inheritParticleInfoToSubEmitters(): void;
  17633. /** @hidden */
  17634. _reset(): void;
  17635. /**
  17636. * Copy the properties of particle to another one.
  17637. * @param other the particle to copy the information to.
  17638. */
  17639. copyTo(other: Particle): void;
  17640. }
  17641. }
  17642. declare module BABYLON {
  17643. /**
  17644. * Particle emitter represents a volume emitting particles.
  17645. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17646. */
  17647. export interface IParticleEmitterType {
  17648. /**
  17649. * Called by the particle System when the direction is computed for the created particle.
  17650. * @param worldMatrix is the world matrix of the particle system
  17651. * @param directionToUpdate is the direction vector to update with the result
  17652. * @param particle is the particle we are computed the direction for
  17653. */
  17654. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17655. /**
  17656. * Called by the particle System when the position is computed for the created particle.
  17657. * @param worldMatrix is the world matrix of the particle system
  17658. * @param positionToUpdate is the position vector to update with the result
  17659. * @param particle is the particle we are computed the position for
  17660. */
  17661. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17662. /**
  17663. * Clones the current emitter and returns a copy of it
  17664. * @returns the new emitter
  17665. */
  17666. clone(): IParticleEmitterType;
  17667. /**
  17668. * Called by the GPUParticleSystem to setup the update shader
  17669. * @param effect defines the update shader
  17670. */
  17671. applyToShader(effect: Effect): void;
  17672. /**
  17673. * Returns a string to use to update the GPU particles update shader
  17674. * @returns the effect defines string
  17675. */
  17676. getEffectDefines(): string;
  17677. /**
  17678. * Returns a string representing the class name
  17679. * @returns a string containing the class name
  17680. */
  17681. getClassName(): string;
  17682. /**
  17683. * Serializes the particle system to a JSON object.
  17684. * @returns the JSON object
  17685. */
  17686. serialize(): any;
  17687. /**
  17688. * Parse properties from a JSON object
  17689. * @param serializationObject defines the JSON object
  17690. */
  17691. parse(serializationObject: any): void;
  17692. }
  17693. }
  17694. declare module BABYLON {
  17695. /**
  17696. * Particle emitter emitting particles from the inside of a box.
  17697. * It emits the particles randomly between 2 given directions.
  17698. */
  17699. export class BoxParticleEmitter implements IParticleEmitterType {
  17700. /**
  17701. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17702. */
  17703. direction1: Vector3;
  17704. /**
  17705. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17706. */
  17707. direction2: Vector3;
  17708. /**
  17709. * 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.
  17710. */
  17711. minEmitBox: Vector3;
  17712. /**
  17713. * 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.
  17714. */
  17715. maxEmitBox: Vector3;
  17716. /**
  17717. * Creates a new instance BoxParticleEmitter
  17718. */
  17719. constructor();
  17720. /**
  17721. * Called by the particle System when the direction is computed for the created particle.
  17722. * @param worldMatrix is the world matrix of the particle system
  17723. * @param directionToUpdate is the direction vector to update with the result
  17724. * @param particle is the particle we are computed the direction for
  17725. */
  17726. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17727. /**
  17728. * Called by the particle System when the position is computed for the created particle.
  17729. * @param worldMatrix is the world matrix of the particle system
  17730. * @param positionToUpdate is the position vector to update with the result
  17731. * @param particle is the particle we are computed the position for
  17732. */
  17733. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17734. /**
  17735. * Clones the current emitter and returns a copy of it
  17736. * @returns the new emitter
  17737. */
  17738. clone(): BoxParticleEmitter;
  17739. /**
  17740. * Called by the GPUParticleSystem to setup the update shader
  17741. * @param effect defines the update shader
  17742. */
  17743. applyToShader(effect: Effect): void;
  17744. /**
  17745. * Returns a string to use to update the GPU particles update shader
  17746. * @returns a string containng the defines string
  17747. */
  17748. getEffectDefines(): string;
  17749. /**
  17750. * Returns the string "BoxParticleEmitter"
  17751. * @returns a string containing the class name
  17752. */
  17753. getClassName(): string;
  17754. /**
  17755. * Serializes the particle system to a JSON object.
  17756. * @returns the JSON object
  17757. */
  17758. serialize(): any;
  17759. /**
  17760. * Parse properties from a JSON object
  17761. * @param serializationObject defines the JSON object
  17762. */
  17763. parse(serializationObject: any): void;
  17764. }
  17765. }
  17766. declare module BABYLON {
  17767. /**
  17768. * Particle emitter emitting particles from the inside of a cone.
  17769. * It emits the particles alongside the cone volume from the base to the particle.
  17770. * The emission direction might be randomized.
  17771. */
  17772. export class ConeParticleEmitter implements IParticleEmitterType {
  17773. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17774. directionRandomizer: number;
  17775. private _radius;
  17776. private _angle;
  17777. private _height;
  17778. /**
  17779. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17780. */
  17781. radiusRange: number;
  17782. /**
  17783. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17784. */
  17785. heightRange: number;
  17786. /**
  17787. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17788. */
  17789. emitFromSpawnPointOnly: boolean;
  17790. /**
  17791. * Gets or sets the radius of the emission cone
  17792. */
  17793. radius: number;
  17794. /**
  17795. * Gets or sets the angle of the emission cone
  17796. */
  17797. angle: number;
  17798. private _buildHeight;
  17799. /**
  17800. * Creates a new instance ConeParticleEmitter
  17801. * @param radius the radius of the emission cone (1 by default)
  17802. * @param angle the cone base angle (PI by default)
  17803. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17804. */
  17805. constructor(radius?: number, angle?: number,
  17806. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17807. directionRandomizer?: number);
  17808. /**
  17809. * Called by the particle System when the direction is computed for the created particle.
  17810. * @param worldMatrix is the world matrix of the particle system
  17811. * @param directionToUpdate is the direction vector to update with the result
  17812. * @param particle is the particle we are computed the direction for
  17813. */
  17814. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17815. /**
  17816. * Called by the particle System when the position is computed for the created particle.
  17817. * @param worldMatrix is the world matrix of the particle system
  17818. * @param positionToUpdate is the position vector to update with the result
  17819. * @param particle is the particle we are computed the position for
  17820. */
  17821. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17822. /**
  17823. * Clones the current emitter and returns a copy of it
  17824. * @returns the new emitter
  17825. */
  17826. clone(): ConeParticleEmitter;
  17827. /**
  17828. * Called by the GPUParticleSystem to setup the update shader
  17829. * @param effect defines the update shader
  17830. */
  17831. applyToShader(effect: Effect): void;
  17832. /**
  17833. * Returns a string to use to update the GPU particles update shader
  17834. * @returns a string containng the defines string
  17835. */
  17836. getEffectDefines(): string;
  17837. /**
  17838. * Returns the string "ConeParticleEmitter"
  17839. * @returns a string containing the class name
  17840. */
  17841. getClassName(): string;
  17842. /**
  17843. * Serializes the particle system to a JSON object.
  17844. * @returns the JSON object
  17845. */
  17846. serialize(): any;
  17847. /**
  17848. * Parse properties from a JSON object
  17849. * @param serializationObject defines the JSON object
  17850. */
  17851. parse(serializationObject: any): void;
  17852. }
  17853. }
  17854. declare module BABYLON {
  17855. /**
  17856. * Particle emitter emitting particles from the inside of a cylinder.
  17857. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17858. */
  17859. export class CylinderParticleEmitter implements IParticleEmitterType {
  17860. /**
  17861. * The radius of the emission cylinder.
  17862. */
  17863. radius: number;
  17864. /**
  17865. * The height of the emission cylinder.
  17866. */
  17867. height: number;
  17868. /**
  17869. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17870. */
  17871. radiusRange: number;
  17872. /**
  17873. * How much to randomize the particle direction [0-1].
  17874. */
  17875. directionRandomizer: number;
  17876. /**
  17877. * Creates a new instance CylinderParticleEmitter
  17878. * @param radius the radius of the emission cylinder (1 by default)
  17879. * @param height the height of the emission cylinder (1 by default)
  17880. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17881. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17882. */
  17883. constructor(
  17884. /**
  17885. * The radius of the emission cylinder.
  17886. */
  17887. radius?: number,
  17888. /**
  17889. * The height of the emission cylinder.
  17890. */
  17891. height?: number,
  17892. /**
  17893. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17894. */
  17895. radiusRange?: number,
  17896. /**
  17897. * How much to randomize the particle direction [0-1].
  17898. */
  17899. directionRandomizer?: number);
  17900. /**
  17901. * Called by the particle System when the direction is computed for the created particle.
  17902. * @param worldMatrix is the world matrix of the particle system
  17903. * @param directionToUpdate is the direction vector to update with the result
  17904. * @param particle is the particle we are computed the direction for
  17905. */
  17906. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17907. /**
  17908. * Called by the particle System when the position is computed for the created particle.
  17909. * @param worldMatrix is the world matrix of the particle system
  17910. * @param positionToUpdate is the position vector to update with the result
  17911. * @param particle is the particle we are computed the position for
  17912. */
  17913. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17914. /**
  17915. * Clones the current emitter and returns a copy of it
  17916. * @returns the new emitter
  17917. */
  17918. clone(): CylinderParticleEmitter;
  17919. /**
  17920. * Called by the GPUParticleSystem to setup the update shader
  17921. * @param effect defines the update shader
  17922. */
  17923. applyToShader(effect: Effect): void;
  17924. /**
  17925. * Returns a string to use to update the GPU particles update shader
  17926. * @returns a string containng the defines string
  17927. */
  17928. getEffectDefines(): string;
  17929. /**
  17930. * Returns the string "CylinderParticleEmitter"
  17931. * @returns a string containing the class name
  17932. */
  17933. getClassName(): string;
  17934. /**
  17935. * Serializes the particle system to a JSON object.
  17936. * @returns the JSON object
  17937. */
  17938. serialize(): any;
  17939. /**
  17940. * Parse properties from a JSON object
  17941. * @param serializationObject defines the JSON object
  17942. */
  17943. parse(serializationObject: any): void;
  17944. }
  17945. /**
  17946. * Particle emitter emitting particles from the inside of a cylinder.
  17947. * It emits the particles randomly between two vectors.
  17948. */
  17949. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17950. /**
  17951. * The min limit of the emission direction.
  17952. */
  17953. direction1: Vector3;
  17954. /**
  17955. * The max limit of the emission direction.
  17956. */
  17957. direction2: Vector3;
  17958. /**
  17959. * Creates a new instance CylinderDirectedParticleEmitter
  17960. * @param radius the radius of the emission cylinder (1 by default)
  17961. * @param height the height of the emission cylinder (1 by default)
  17962. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17963. * @param direction1 the min limit of the emission direction (up vector by default)
  17964. * @param direction2 the max limit of the emission direction (up vector by default)
  17965. */
  17966. constructor(radius?: number, height?: number, radiusRange?: number,
  17967. /**
  17968. * The min limit of the emission direction.
  17969. */
  17970. direction1?: Vector3,
  17971. /**
  17972. * The max limit of the emission direction.
  17973. */
  17974. direction2?: Vector3);
  17975. /**
  17976. * Called by the particle System when the direction is computed for the created particle.
  17977. * @param worldMatrix is the world matrix of the particle system
  17978. * @param directionToUpdate is the direction vector to update with the result
  17979. * @param particle is the particle we are computed the direction for
  17980. */
  17981. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17982. /**
  17983. * Clones the current emitter and returns a copy of it
  17984. * @returns the new emitter
  17985. */
  17986. clone(): CylinderDirectedParticleEmitter;
  17987. /**
  17988. * Called by the GPUParticleSystem to setup the update shader
  17989. * @param effect defines the update shader
  17990. */
  17991. applyToShader(effect: Effect): void;
  17992. /**
  17993. * Returns a string to use to update the GPU particles update shader
  17994. * @returns a string containng the defines string
  17995. */
  17996. getEffectDefines(): string;
  17997. /**
  17998. * Returns the string "CylinderDirectedParticleEmitter"
  17999. * @returns a string containing the class name
  18000. */
  18001. getClassName(): string;
  18002. /**
  18003. * Serializes the particle system to a JSON object.
  18004. * @returns the JSON object
  18005. */
  18006. serialize(): any;
  18007. /**
  18008. * Parse properties from a JSON object
  18009. * @param serializationObject defines the JSON object
  18010. */
  18011. parse(serializationObject: any): void;
  18012. }
  18013. }
  18014. declare module BABYLON {
  18015. /**
  18016. * Particle emitter emitting particles from the inside of a hemisphere.
  18017. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18018. */
  18019. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18020. /**
  18021. * The radius of the emission hemisphere.
  18022. */
  18023. radius: number;
  18024. /**
  18025. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18026. */
  18027. radiusRange: number;
  18028. /**
  18029. * How much to randomize the particle direction [0-1].
  18030. */
  18031. directionRandomizer: number;
  18032. /**
  18033. * Creates a new instance HemisphericParticleEmitter
  18034. * @param radius the radius of the emission hemisphere (1 by default)
  18035. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18036. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18037. */
  18038. constructor(
  18039. /**
  18040. * The radius of the emission hemisphere.
  18041. */
  18042. radius?: number,
  18043. /**
  18044. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18045. */
  18046. radiusRange?: number,
  18047. /**
  18048. * How much to randomize the particle direction [0-1].
  18049. */
  18050. directionRandomizer?: number);
  18051. /**
  18052. * Called by the particle System when the direction is computed for the created particle.
  18053. * @param worldMatrix is the world matrix of the particle system
  18054. * @param directionToUpdate is the direction vector to update with the result
  18055. * @param particle is the particle we are computed the direction for
  18056. */
  18057. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18058. /**
  18059. * Called by the particle System when the position is computed for the created particle.
  18060. * @param worldMatrix is the world matrix of the particle system
  18061. * @param positionToUpdate is the position vector to update with the result
  18062. * @param particle is the particle we are computed the position for
  18063. */
  18064. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18065. /**
  18066. * Clones the current emitter and returns a copy of it
  18067. * @returns the new emitter
  18068. */
  18069. clone(): HemisphericParticleEmitter;
  18070. /**
  18071. * Called by the GPUParticleSystem to setup the update shader
  18072. * @param effect defines the update shader
  18073. */
  18074. applyToShader(effect: Effect): void;
  18075. /**
  18076. * Returns a string to use to update the GPU particles update shader
  18077. * @returns a string containng the defines string
  18078. */
  18079. getEffectDefines(): string;
  18080. /**
  18081. * Returns the string "HemisphericParticleEmitter"
  18082. * @returns a string containing the class name
  18083. */
  18084. getClassName(): string;
  18085. /**
  18086. * Serializes the particle system to a JSON object.
  18087. * @returns the JSON object
  18088. */
  18089. serialize(): any;
  18090. /**
  18091. * Parse properties from a JSON object
  18092. * @param serializationObject defines the JSON object
  18093. */
  18094. parse(serializationObject: any): void;
  18095. }
  18096. }
  18097. declare module BABYLON {
  18098. /**
  18099. * Particle emitter emitting particles from a point.
  18100. * It emits the particles randomly between 2 given directions.
  18101. */
  18102. export class PointParticleEmitter implements IParticleEmitterType {
  18103. /**
  18104. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18105. */
  18106. direction1: Vector3;
  18107. /**
  18108. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18109. */
  18110. direction2: Vector3;
  18111. /**
  18112. * Creates a new instance PointParticleEmitter
  18113. */
  18114. constructor();
  18115. /**
  18116. * Called by the particle System when the direction is computed for the created particle.
  18117. * @param worldMatrix is the world matrix of the particle system
  18118. * @param directionToUpdate is the direction vector to update with the result
  18119. * @param particle is the particle we are computed the direction for
  18120. */
  18121. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18122. /**
  18123. * Called by the particle System when the position is computed for the created particle.
  18124. * @param worldMatrix is the world matrix of the particle system
  18125. * @param positionToUpdate is the position vector to update with the result
  18126. * @param particle is the particle we are computed the position for
  18127. */
  18128. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18129. /**
  18130. * Clones the current emitter and returns a copy of it
  18131. * @returns the new emitter
  18132. */
  18133. clone(): PointParticleEmitter;
  18134. /**
  18135. * Called by the GPUParticleSystem to setup the update shader
  18136. * @param effect defines the update shader
  18137. */
  18138. applyToShader(effect: Effect): void;
  18139. /**
  18140. * Returns a string to use to update the GPU particles update shader
  18141. * @returns a string containng the defines string
  18142. */
  18143. getEffectDefines(): string;
  18144. /**
  18145. * Returns the string "PointParticleEmitter"
  18146. * @returns a string containing the class name
  18147. */
  18148. getClassName(): string;
  18149. /**
  18150. * Serializes the particle system to a JSON object.
  18151. * @returns the JSON object
  18152. */
  18153. serialize(): any;
  18154. /**
  18155. * Parse properties from a JSON object
  18156. * @param serializationObject defines the JSON object
  18157. */
  18158. parse(serializationObject: any): void;
  18159. }
  18160. }
  18161. declare module BABYLON {
  18162. /**
  18163. * Particle emitter emitting particles from the inside of a sphere.
  18164. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18165. */
  18166. export class SphereParticleEmitter implements IParticleEmitterType {
  18167. /**
  18168. * The radius of the emission sphere.
  18169. */
  18170. radius: number;
  18171. /**
  18172. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18173. */
  18174. radiusRange: number;
  18175. /**
  18176. * How much to randomize the particle direction [0-1].
  18177. */
  18178. directionRandomizer: number;
  18179. /**
  18180. * Creates a new instance SphereParticleEmitter
  18181. * @param radius the radius of the emission sphere (1 by default)
  18182. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18183. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18184. */
  18185. constructor(
  18186. /**
  18187. * The radius of the emission sphere.
  18188. */
  18189. radius?: number,
  18190. /**
  18191. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18192. */
  18193. radiusRange?: number,
  18194. /**
  18195. * How much to randomize the particle direction [0-1].
  18196. */
  18197. directionRandomizer?: number);
  18198. /**
  18199. * Called by the particle System when the direction is computed for the created particle.
  18200. * @param worldMatrix is the world matrix of the particle system
  18201. * @param directionToUpdate is the direction vector to update with the result
  18202. * @param particle is the particle we are computed the direction for
  18203. */
  18204. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18205. /**
  18206. * Called by the particle System when the position is computed for the created particle.
  18207. * @param worldMatrix is the world matrix of the particle system
  18208. * @param positionToUpdate is the position vector to update with the result
  18209. * @param particle is the particle we are computed the position for
  18210. */
  18211. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18212. /**
  18213. * Clones the current emitter and returns a copy of it
  18214. * @returns the new emitter
  18215. */
  18216. clone(): SphereParticleEmitter;
  18217. /**
  18218. * Called by the GPUParticleSystem to setup the update shader
  18219. * @param effect defines the update shader
  18220. */
  18221. applyToShader(effect: Effect): void;
  18222. /**
  18223. * Returns a string to use to update the GPU particles update shader
  18224. * @returns a string containng the defines string
  18225. */
  18226. getEffectDefines(): string;
  18227. /**
  18228. * Returns the string "SphereParticleEmitter"
  18229. * @returns a string containing the class name
  18230. */
  18231. getClassName(): string;
  18232. /**
  18233. * Serializes the particle system to a JSON object.
  18234. * @returns the JSON object
  18235. */
  18236. serialize(): any;
  18237. /**
  18238. * Parse properties from a JSON object
  18239. * @param serializationObject defines the JSON object
  18240. */
  18241. parse(serializationObject: any): void;
  18242. }
  18243. /**
  18244. * Particle emitter emitting particles from the inside of a sphere.
  18245. * It emits the particles randomly between two vectors.
  18246. */
  18247. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18248. /**
  18249. * The min limit of the emission direction.
  18250. */
  18251. direction1: Vector3;
  18252. /**
  18253. * The max limit of the emission direction.
  18254. */
  18255. direction2: Vector3;
  18256. /**
  18257. * Creates a new instance SphereDirectedParticleEmitter
  18258. * @param radius the radius of the emission sphere (1 by default)
  18259. * @param direction1 the min limit of the emission direction (up vector by default)
  18260. * @param direction2 the max limit of the emission direction (up vector by default)
  18261. */
  18262. constructor(radius?: number,
  18263. /**
  18264. * The min limit of the emission direction.
  18265. */
  18266. direction1?: Vector3,
  18267. /**
  18268. * The max limit of the emission direction.
  18269. */
  18270. direction2?: Vector3);
  18271. /**
  18272. * Called by the particle System when the direction is computed for the created particle.
  18273. * @param worldMatrix is the world matrix of the particle system
  18274. * @param directionToUpdate is the direction vector to update with the result
  18275. * @param particle is the particle we are computed the direction for
  18276. */
  18277. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18278. /**
  18279. * Clones the current emitter and returns a copy of it
  18280. * @returns the new emitter
  18281. */
  18282. clone(): SphereDirectedParticleEmitter;
  18283. /**
  18284. * Called by the GPUParticleSystem to setup the update shader
  18285. * @param effect defines the update shader
  18286. */
  18287. applyToShader(effect: Effect): void;
  18288. /**
  18289. * Returns a string to use to update the GPU particles update shader
  18290. * @returns a string containng the defines string
  18291. */
  18292. getEffectDefines(): string;
  18293. /**
  18294. * Returns the string "SphereDirectedParticleEmitter"
  18295. * @returns a string containing the class name
  18296. */
  18297. getClassName(): string;
  18298. /**
  18299. * Serializes the particle system to a JSON object.
  18300. * @returns the JSON object
  18301. */
  18302. serialize(): any;
  18303. /**
  18304. * Parse properties from a JSON object
  18305. * @param serializationObject defines the JSON object
  18306. */
  18307. parse(serializationObject: any): void;
  18308. }
  18309. }
  18310. declare module BABYLON {
  18311. /**
  18312. * Interface representing a particle system in Babylon.js.
  18313. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18314. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18315. */
  18316. export interface IParticleSystem {
  18317. /**
  18318. * List of animations used by the particle system.
  18319. */
  18320. animations: Animation[];
  18321. /**
  18322. * The id of the Particle system.
  18323. */
  18324. id: string;
  18325. /**
  18326. * The name of the Particle system.
  18327. */
  18328. name: string;
  18329. /**
  18330. * The emitter represents the Mesh or position we are attaching the particle system to.
  18331. */
  18332. emitter: Nullable<AbstractMesh | Vector3>;
  18333. /**
  18334. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18335. */
  18336. isBillboardBased: boolean;
  18337. /**
  18338. * The rendering group used by the Particle system to chose when to render.
  18339. */
  18340. renderingGroupId: number;
  18341. /**
  18342. * The layer mask we are rendering the particles through.
  18343. */
  18344. layerMask: number;
  18345. /**
  18346. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18347. */
  18348. updateSpeed: number;
  18349. /**
  18350. * The amount of time the particle system is running (depends of the overall update speed).
  18351. */
  18352. targetStopDuration: number;
  18353. /**
  18354. * The texture used to render each particle. (this can be a spritesheet)
  18355. */
  18356. particleTexture: Nullable<Texture>;
  18357. /**
  18358. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18359. */
  18360. blendMode: number;
  18361. /**
  18362. * Minimum life time of emitting particles.
  18363. */
  18364. minLifeTime: number;
  18365. /**
  18366. * Maximum life time of emitting particles.
  18367. */
  18368. maxLifeTime: number;
  18369. /**
  18370. * Minimum Size of emitting particles.
  18371. */
  18372. minSize: number;
  18373. /**
  18374. * Maximum Size of emitting particles.
  18375. */
  18376. maxSize: number;
  18377. /**
  18378. * Minimum scale of emitting particles on X axis.
  18379. */
  18380. minScaleX: number;
  18381. /**
  18382. * Maximum scale of emitting particles on X axis.
  18383. */
  18384. maxScaleX: number;
  18385. /**
  18386. * Minimum scale of emitting particles on Y axis.
  18387. */
  18388. minScaleY: number;
  18389. /**
  18390. * Maximum scale of emitting particles on Y axis.
  18391. */
  18392. maxScaleY: number;
  18393. /**
  18394. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18395. */
  18396. color1: Color4;
  18397. /**
  18398. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18399. */
  18400. color2: Color4;
  18401. /**
  18402. * Color the particle will have at the end of its lifetime.
  18403. */
  18404. colorDead: Color4;
  18405. /**
  18406. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18407. */
  18408. emitRate: number;
  18409. /**
  18410. * You can use gravity if you want to give an orientation to your particles.
  18411. */
  18412. gravity: Vector3;
  18413. /**
  18414. * Minimum power of emitting particles.
  18415. */
  18416. minEmitPower: number;
  18417. /**
  18418. * Maximum power of emitting particles.
  18419. */
  18420. maxEmitPower: number;
  18421. /**
  18422. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18423. */
  18424. minAngularSpeed: number;
  18425. /**
  18426. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18427. */
  18428. maxAngularSpeed: number;
  18429. /**
  18430. * Gets or sets the minimal initial rotation in radians.
  18431. */
  18432. minInitialRotation: number;
  18433. /**
  18434. * Gets or sets the maximal initial rotation in radians.
  18435. */
  18436. maxInitialRotation: number;
  18437. /**
  18438. * The particle emitter type defines the emitter used by the particle system.
  18439. * It can be for example box, sphere, or cone...
  18440. */
  18441. particleEmitterType: Nullable<IParticleEmitterType>;
  18442. /**
  18443. * Defines the delay in milliseconds before starting the system (0 by default)
  18444. */
  18445. startDelay: number;
  18446. /**
  18447. * 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
  18448. */
  18449. preWarmCycles: number;
  18450. /**
  18451. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18452. */
  18453. preWarmStepOffset: number;
  18454. /**
  18455. * 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)
  18456. */
  18457. spriteCellChangeSpeed: number;
  18458. /**
  18459. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18460. */
  18461. startSpriteCellID: number;
  18462. /**
  18463. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18464. */
  18465. endSpriteCellID: number;
  18466. /**
  18467. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18468. */
  18469. spriteCellWidth: number;
  18470. /**
  18471. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18472. */
  18473. spriteCellHeight: number;
  18474. /**
  18475. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18476. */
  18477. spriteRandomStartCell: boolean;
  18478. /**
  18479. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18480. */
  18481. isAnimationSheetEnabled: boolean;
  18482. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18483. translationPivot: Vector2;
  18484. /**
  18485. * Gets or sets a texture used to add random noise to particle positions
  18486. */
  18487. noiseTexture: Nullable<BaseTexture>;
  18488. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18489. noiseStrength: Vector3;
  18490. /**
  18491. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18492. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18493. */
  18494. billboardMode: number;
  18495. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18496. limitVelocityDamping: number;
  18497. /**
  18498. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18499. */
  18500. beginAnimationOnStart: boolean;
  18501. /**
  18502. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18503. */
  18504. beginAnimationFrom: number;
  18505. /**
  18506. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18507. */
  18508. beginAnimationTo: number;
  18509. /**
  18510. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18511. */
  18512. beginAnimationLoop: boolean;
  18513. /**
  18514. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18515. */
  18516. disposeOnStop: boolean;
  18517. /**
  18518. * Gets the maximum number of particles active at the same time.
  18519. * @returns The max number of active particles.
  18520. */
  18521. getCapacity(): number;
  18522. /**
  18523. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18524. * @returns True if it has been started, otherwise false.
  18525. */
  18526. isStarted(): boolean;
  18527. /**
  18528. * Animates the particle system for this frame.
  18529. */
  18530. animate(): void;
  18531. /**
  18532. * Renders the particle system in its current state.
  18533. * @returns the current number of particles
  18534. */
  18535. render(): number;
  18536. /**
  18537. * Dispose the particle system and frees its associated resources.
  18538. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18539. */
  18540. dispose(disposeTexture?: boolean): void;
  18541. /**
  18542. * Clones the particle system.
  18543. * @param name The name of the cloned object
  18544. * @param newEmitter The new emitter to use
  18545. * @returns the cloned particle system
  18546. */
  18547. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18548. /**
  18549. * Serializes the particle system to a JSON object.
  18550. * @returns the JSON object
  18551. */
  18552. serialize(): any;
  18553. /**
  18554. * Rebuild the particle system
  18555. */
  18556. rebuild(): void;
  18557. /**
  18558. * Starts the particle system and begins to emit
  18559. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18560. */
  18561. start(delay?: number): void;
  18562. /**
  18563. * Stops the particle system.
  18564. */
  18565. stop(): void;
  18566. /**
  18567. * Remove all active particles
  18568. */
  18569. reset(): void;
  18570. /**
  18571. * Is this system ready to be used/rendered
  18572. * @return true if the system is ready
  18573. */
  18574. isReady(): boolean;
  18575. /**
  18576. * Adds a new color gradient
  18577. * @param gradient defines the gradient to use (between 0 and 1)
  18578. * @param color1 defines the color to affect to the specified gradient
  18579. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18580. * @returns the current particle system
  18581. */
  18582. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18583. /**
  18584. * Remove a specific color gradient
  18585. * @param gradient defines the gradient to remove
  18586. * @returns the current particle system
  18587. */
  18588. removeColorGradient(gradient: number): IParticleSystem;
  18589. /**
  18590. * Adds a new size gradient
  18591. * @param gradient defines the gradient to use (between 0 and 1)
  18592. * @param factor defines the size factor to affect to the specified gradient
  18593. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18594. * @returns the current particle system
  18595. */
  18596. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18597. /**
  18598. * Remove a specific size gradient
  18599. * @param gradient defines the gradient to remove
  18600. * @returns the current particle system
  18601. */
  18602. removeSizeGradient(gradient: number): IParticleSystem;
  18603. /**
  18604. * Gets the current list of color gradients.
  18605. * You must use addColorGradient and removeColorGradient to udpate this list
  18606. * @returns the list of color gradients
  18607. */
  18608. getColorGradients(): Nullable<Array<ColorGradient>>;
  18609. /**
  18610. * Gets the current list of size gradients.
  18611. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18612. * @returns the list of size gradients
  18613. */
  18614. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18615. /**
  18616. * Gets the current list of angular speed gradients.
  18617. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18618. * @returns the list of angular speed gradients
  18619. */
  18620. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18621. /**
  18622. * Adds a new angular speed gradient
  18623. * @param gradient defines the gradient to use (between 0 and 1)
  18624. * @param factor defines the angular speed to affect to the specified gradient
  18625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18626. * @returns the current particle system
  18627. */
  18628. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18629. /**
  18630. * Remove a specific angular speed gradient
  18631. * @param gradient defines the gradient to remove
  18632. * @returns the current particle system
  18633. */
  18634. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18635. /**
  18636. * Gets the current list of velocity gradients.
  18637. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18638. * @returns the list of velocity gradients
  18639. */
  18640. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18641. /**
  18642. * Adds a new velocity gradient
  18643. * @param gradient defines the gradient to use (between 0 and 1)
  18644. * @param factor defines the velocity to affect to the specified gradient
  18645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18646. * @returns the current particle system
  18647. */
  18648. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18649. /**
  18650. * Remove a specific velocity gradient
  18651. * @param gradient defines the gradient to remove
  18652. * @returns the current particle system
  18653. */
  18654. removeVelocityGradient(gradient: number): IParticleSystem;
  18655. /**
  18656. * Gets the current list of limit velocity gradients.
  18657. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18658. * @returns the list of limit velocity gradients
  18659. */
  18660. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18661. /**
  18662. * Adds a new limit velocity gradient
  18663. * @param gradient defines the gradient to use (between 0 and 1)
  18664. * @param factor defines the limit velocity to affect to the specified gradient
  18665. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18666. * @returns the current particle system
  18667. */
  18668. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18669. /**
  18670. * Remove a specific limit velocity gradient
  18671. * @param gradient defines the gradient to remove
  18672. * @returns the current particle system
  18673. */
  18674. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18675. /**
  18676. * Adds a new drag gradient
  18677. * @param gradient defines the gradient to use (between 0 and 1)
  18678. * @param factor defines the drag to affect to the specified gradient
  18679. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18680. * @returns the current particle system
  18681. */
  18682. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18683. /**
  18684. * Remove a specific drag gradient
  18685. * @param gradient defines the gradient to remove
  18686. * @returns the current particle system
  18687. */
  18688. removeDragGradient(gradient: number): IParticleSystem;
  18689. /**
  18690. * Gets the current list of drag gradients.
  18691. * You must use addDragGradient and removeDragGradient to udpate this list
  18692. * @returns the list of drag gradients
  18693. */
  18694. getDragGradients(): Nullable<Array<FactorGradient>>;
  18695. /**
  18696. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18697. * @param gradient defines the gradient to use (between 0 and 1)
  18698. * @param factor defines the emit rate to affect to the specified gradient
  18699. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18700. * @returns the current particle system
  18701. */
  18702. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18703. /**
  18704. * Remove a specific emit rate gradient
  18705. * @param gradient defines the gradient to remove
  18706. * @returns the current particle system
  18707. */
  18708. removeEmitRateGradient(gradient: number): IParticleSystem;
  18709. /**
  18710. * Gets the current list of emit rate gradients.
  18711. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18712. * @returns the list of emit rate gradients
  18713. */
  18714. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18715. /**
  18716. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18717. * @param gradient defines the gradient to use (between 0 and 1)
  18718. * @param factor defines the start size to affect to the specified gradient
  18719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18720. * @returns the current particle system
  18721. */
  18722. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18723. /**
  18724. * Remove a specific start size gradient
  18725. * @param gradient defines the gradient to remove
  18726. * @returns the current particle system
  18727. */
  18728. removeStartSizeGradient(gradient: number): IParticleSystem;
  18729. /**
  18730. * Gets the current list of start size gradients.
  18731. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18732. * @returns the list of start size gradients
  18733. */
  18734. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18735. /**
  18736. * Adds a new life time gradient
  18737. * @param gradient defines the gradient to use (between 0 and 1)
  18738. * @param factor defines the life time factor to affect to the specified gradient
  18739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18740. * @returns the current particle system
  18741. */
  18742. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18743. /**
  18744. * Remove a specific life time gradient
  18745. * @param gradient defines the gradient to remove
  18746. * @returns the current particle system
  18747. */
  18748. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18749. /**
  18750. * Gets the current list of life time gradients.
  18751. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18752. * @returns the list of life time gradients
  18753. */
  18754. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18755. /**
  18756. * Gets the current list of color gradients.
  18757. * You must use addColorGradient and removeColorGradient to udpate this list
  18758. * @returns the list of color gradients
  18759. */
  18760. getColorGradients(): Nullable<Array<ColorGradient>>;
  18761. /**
  18762. * Adds a new ramp gradient used to remap particle colors
  18763. * @param gradient defines the gradient to use (between 0 and 1)
  18764. * @param color defines the color to affect to the specified gradient
  18765. * @returns the current particle system
  18766. */
  18767. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18768. /**
  18769. * Gets the current list of ramp gradients.
  18770. * You must use addRampGradient and removeRampGradient to udpate this list
  18771. * @returns the list of ramp gradients
  18772. */
  18773. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18774. /** Gets or sets a boolean indicating that ramp gradients must be used
  18775. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18776. */
  18777. useRampGradients: boolean;
  18778. /**
  18779. * Adds a new color remap gradient
  18780. * @param gradient defines the gradient to use (between 0 and 1)
  18781. * @param min defines the color remap minimal range
  18782. * @param max defines the color remap maximal range
  18783. * @returns the current particle system
  18784. */
  18785. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18786. /**
  18787. * Gets the current list of color remap gradients.
  18788. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18789. * @returns the list of color remap gradients
  18790. */
  18791. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18792. /**
  18793. * Adds a new alpha remap gradient
  18794. * @param gradient defines the gradient to use (between 0 and 1)
  18795. * @param min defines the alpha remap minimal range
  18796. * @param max defines the alpha remap maximal range
  18797. * @returns the current particle system
  18798. */
  18799. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18800. /**
  18801. * Gets the current list of alpha remap gradients.
  18802. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18803. * @returns the list of alpha remap gradients
  18804. */
  18805. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18806. /**
  18807. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18808. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18809. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18810. * @returns the emitter
  18811. */
  18812. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18813. /**
  18814. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18815. * @param radius The radius of the hemisphere to emit from
  18816. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18817. * @returns the emitter
  18818. */
  18819. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18820. /**
  18821. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18822. * @param radius The radius of the sphere to emit from
  18823. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18824. * @returns the emitter
  18825. */
  18826. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18827. /**
  18828. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18829. * @param radius The radius of the sphere to emit from
  18830. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18831. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18832. * @returns the emitter
  18833. */
  18834. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18835. /**
  18836. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18837. * @param radius The radius of the emission cylinder
  18838. * @param height The height of the emission cylinder
  18839. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18840. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18841. * @returns the emitter
  18842. */
  18843. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18844. /**
  18845. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18846. * @param radius The radius of the cylinder to emit from
  18847. * @param height The height of the emission cylinder
  18848. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18849. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18850. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18851. * @returns the emitter
  18852. */
  18853. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18854. /**
  18855. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18856. * @param radius The radius of the cone to emit from
  18857. * @param angle The base angle of the cone
  18858. * @returns the emitter
  18859. */
  18860. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18861. /**
  18862. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18863. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18864. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18865. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18866. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18867. * @returns the emitter
  18868. */
  18869. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18870. /**
  18871. * Get hosting scene
  18872. * @returns the scene
  18873. */
  18874. getScene(): Scene;
  18875. }
  18876. }
  18877. declare module BABYLON {
  18878. /**
  18879. * Creates an instance based on a source mesh.
  18880. */
  18881. export class InstancedMesh extends AbstractMesh {
  18882. private _sourceMesh;
  18883. private _currentLOD;
  18884. /** @hidden */
  18885. _indexInSourceMeshInstanceArray: number;
  18886. constructor(name: string, source: Mesh);
  18887. /**
  18888. * Returns the string "InstancedMesh".
  18889. */
  18890. getClassName(): string;
  18891. /** Gets the list of lights affecting that mesh */
  18892. readonly lightSources: Light[];
  18893. _resyncLightSources(): void;
  18894. _resyncLighSource(light: Light): void;
  18895. _removeLightSource(light: Light, dispose: boolean): void;
  18896. /**
  18897. * If the source mesh receives shadows
  18898. */
  18899. readonly receiveShadows: boolean;
  18900. /**
  18901. * The material of the source mesh
  18902. */
  18903. readonly material: Nullable<Material>;
  18904. /**
  18905. * Visibility of the source mesh
  18906. */
  18907. readonly visibility: number;
  18908. /**
  18909. * Skeleton of the source mesh
  18910. */
  18911. readonly skeleton: Nullable<Skeleton>;
  18912. /**
  18913. * Rendering ground id of the source mesh
  18914. */
  18915. renderingGroupId: number;
  18916. /**
  18917. * Returns the total number of vertices (integer).
  18918. */
  18919. getTotalVertices(): number;
  18920. /**
  18921. * Returns a positive integer : the total number of indices in this mesh geometry.
  18922. * @returns the numner of indices or zero if the mesh has no geometry.
  18923. */
  18924. getTotalIndices(): number;
  18925. /**
  18926. * The source mesh of the instance
  18927. */
  18928. readonly sourceMesh: Mesh;
  18929. /**
  18930. * Is this node ready to be used/rendered
  18931. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18932. * @return {boolean} is it ready
  18933. */
  18934. isReady(completeCheck?: boolean): boolean;
  18935. /**
  18936. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18937. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18938. * @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.
  18939. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18940. */
  18941. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18942. /**
  18943. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18944. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18945. * The `data` are either a numeric array either a Float32Array.
  18946. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18947. * 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).
  18948. * Note that a new underlying VertexBuffer object is created each call.
  18949. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18950. *
  18951. * Possible `kind` values :
  18952. * - VertexBuffer.PositionKind
  18953. * - VertexBuffer.UVKind
  18954. * - VertexBuffer.UV2Kind
  18955. * - VertexBuffer.UV3Kind
  18956. * - VertexBuffer.UV4Kind
  18957. * - VertexBuffer.UV5Kind
  18958. * - VertexBuffer.UV6Kind
  18959. * - VertexBuffer.ColorKind
  18960. * - VertexBuffer.MatricesIndicesKind
  18961. * - VertexBuffer.MatricesIndicesExtraKind
  18962. * - VertexBuffer.MatricesWeightsKind
  18963. * - VertexBuffer.MatricesWeightsExtraKind
  18964. *
  18965. * Returns the Mesh.
  18966. */
  18967. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18968. /**
  18969. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18970. * If the mesh has no geometry, it is simply returned as it is.
  18971. * The `data` are either a numeric array either a Float32Array.
  18972. * No new underlying VertexBuffer object is created.
  18973. * 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.
  18974. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18975. *
  18976. * Possible `kind` values :
  18977. * - VertexBuffer.PositionKind
  18978. * - VertexBuffer.UVKind
  18979. * - VertexBuffer.UV2Kind
  18980. * - VertexBuffer.UV3Kind
  18981. * - VertexBuffer.UV4Kind
  18982. * - VertexBuffer.UV5Kind
  18983. * - VertexBuffer.UV6Kind
  18984. * - VertexBuffer.ColorKind
  18985. * - VertexBuffer.MatricesIndicesKind
  18986. * - VertexBuffer.MatricesIndicesExtraKind
  18987. * - VertexBuffer.MatricesWeightsKind
  18988. * - VertexBuffer.MatricesWeightsExtraKind
  18989. *
  18990. * Returns the Mesh.
  18991. */
  18992. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18993. /**
  18994. * Sets the mesh indices.
  18995. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18996. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18997. * This method creates a new index buffer each call.
  18998. * Returns the Mesh.
  18999. */
  19000. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19001. /**
  19002. * Boolean : True if the mesh owns the requested kind of data.
  19003. */
  19004. isVerticesDataPresent(kind: string): boolean;
  19005. /**
  19006. * Returns an array of indices (IndicesArray).
  19007. */
  19008. getIndices(): Nullable<IndicesArray>;
  19009. readonly _positions: Nullable<Vector3[]>;
  19010. /**
  19011. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19012. * This means the mesh underlying bounding box and sphere are recomputed.
  19013. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19014. * @returns the current mesh
  19015. */
  19016. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19017. /** @hidden */
  19018. _preActivate(): InstancedMesh;
  19019. /** @hidden */
  19020. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19021. /** @hidden */
  19022. _postActivate(): void;
  19023. getWorldMatrix(): Matrix;
  19024. readonly isAnInstance: boolean;
  19025. /**
  19026. * Returns the current associated LOD AbstractMesh.
  19027. */
  19028. getLOD(camera: Camera): AbstractMesh;
  19029. /** @hidden */
  19030. _syncSubMeshes(): InstancedMesh;
  19031. /** @hidden */
  19032. _generatePointsArray(): boolean;
  19033. /**
  19034. * Creates a new InstancedMesh from the current mesh.
  19035. * - name (string) : the cloned mesh name
  19036. * - newParent (optional Node) : the optional Node to parent the clone to.
  19037. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19038. *
  19039. * Returns the clone.
  19040. */
  19041. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19042. /**
  19043. * Disposes the InstancedMesh.
  19044. * Returns nothing.
  19045. */
  19046. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19047. }
  19048. }
  19049. declare module BABYLON {
  19050. /**
  19051. * Defines the options associated with the creation of a shader material.
  19052. */
  19053. export interface IShaderMaterialOptions {
  19054. /**
  19055. * Does the material work in alpha blend mode
  19056. */
  19057. needAlphaBlending: boolean;
  19058. /**
  19059. * Does the material work in alpha test mode
  19060. */
  19061. needAlphaTesting: boolean;
  19062. /**
  19063. * The list of attribute names used in the shader
  19064. */
  19065. attributes: string[];
  19066. /**
  19067. * The list of unifrom names used in the shader
  19068. */
  19069. uniforms: string[];
  19070. /**
  19071. * The list of UBO names used in the shader
  19072. */
  19073. uniformBuffers: string[];
  19074. /**
  19075. * The list of sampler names used in the shader
  19076. */
  19077. samplers: string[];
  19078. /**
  19079. * The list of defines used in the shader
  19080. */
  19081. defines: string[];
  19082. }
  19083. /**
  19084. * 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.
  19085. *
  19086. * This returned material effects how the mesh will look based on the code in the shaders.
  19087. *
  19088. * @see http://doc.babylonjs.com/how_to/shader_material
  19089. */
  19090. export class ShaderMaterial extends Material {
  19091. private _shaderPath;
  19092. private _options;
  19093. private _textures;
  19094. private _textureArrays;
  19095. private _floats;
  19096. private _ints;
  19097. private _floatsArrays;
  19098. private _colors3;
  19099. private _colors3Arrays;
  19100. private _colors4;
  19101. private _colors4Arrays;
  19102. private _vectors2;
  19103. private _vectors3;
  19104. private _vectors4;
  19105. private _matrices;
  19106. private _matrices3x3;
  19107. private _matrices2x2;
  19108. private _vectors2Arrays;
  19109. private _vectors3Arrays;
  19110. private _vectors4Arrays;
  19111. private _cachedWorldViewMatrix;
  19112. private _cachedWorldViewProjectionMatrix;
  19113. private _renderId;
  19114. /**
  19115. * Instantiate a new shader material.
  19116. * 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.
  19117. * This returned material effects how the mesh will look based on the code in the shaders.
  19118. * @see http://doc.babylonjs.com/how_to/shader_material
  19119. * @param name Define the name of the material in the scene
  19120. * @param scene Define the scene the material belongs to
  19121. * @param shaderPath Defines the route to the shader code in one of three ways:
  19122. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19123. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19124. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19125. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19126. * @param options Define the options used to create the shader
  19127. */
  19128. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19129. /**
  19130. * Gets the options used to compile the shader.
  19131. * They can be modified to trigger a new compilation
  19132. */
  19133. readonly options: IShaderMaterialOptions;
  19134. /**
  19135. * Gets the current class name of the material e.g. "ShaderMaterial"
  19136. * Mainly use in serialization.
  19137. * @returns the class name
  19138. */
  19139. getClassName(): string;
  19140. /**
  19141. * Specifies if the material will require alpha blending
  19142. * @returns a boolean specifying if alpha blending is needed
  19143. */
  19144. needAlphaBlending(): boolean;
  19145. /**
  19146. * Specifies if this material should be rendered in alpha test mode
  19147. * @returns a boolean specifying if an alpha test is needed.
  19148. */
  19149. needAlphaTesting(): boolean;
  19150. private _checkUniform;
  19151. /**
  19152. * Set a texture in the shader.
  19153. * @param name Define the name of the uniform samplers as defined in the shader
  19154. * @param texture Define the texture to bind to this sampler
  19155. * @return the material itself allowing "fluent" like uniform updates
  19156. */
  19157. setTexture(name: string, texture: Texture): ShaderMaterial;
  19158. /**
  19159. * Set a texture array in the shader.
  19160. * @param name Define the name of the uniform sampler array as defined in the shader
  19161. * @param textures Define the list of textures to bind to this sampler
  19162. * @return the material itself allowing "fluent" like uniform updates
  19163. */
  19164. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19165. /**
  19166. * Set a float in the shader.
  19167. * @param name Define the name of the uniform as defined in the shader
  19168. * @param value Define the value to give to the uniform
  19169. * @return the material itself allowing "fluent" like uniform updates
  19170. */
  19171. setFloat(name: string, value: number): ShaderMaterial;
  19172. /**
  19173. * Set a int in the shader.
  19174. * @param name Define the name of the uniform as defined in the shader
  19175. * @param value Define the value to give to the uniform
  19176. * @return the material itself allowing "fluent" like uniform updates
  19177. */
  19178. setInt(name: string, value: number): ShaderMaterial;
  19179. /**
  19180. * Set an array of floats in the shader.
  19181. * @param name Define the name of the uniform as defined in the shader
  19182. * @param value Define the value to give to the uniform
  19183. * @return the material itself allowing "fluent" like uniform updates
  19184. */
  19185. setFloats(name: string, value: number[]): ShaderMaterial;
  19186. /**
  19187. * Set a vec3 in the shader from a Color3.
  19188. * @param name Define the name of the uniform as defined in the shader
  19189. * @param value Define the value to give to the uniform
  19190. * @return the material itself allowing "fluent" like uniform updates
  19191. */
  19192. setColor3(name: string, value: Color3): ShaderMaterial;
  19193. /**
  19194. * Set a vec3 array in the shader from a Color3 array.
  19195. * @param name Define the name of the uniform as defined in the shader
  19196. * @param value Define the value to give to the uniform
  19197. * @return the material itself allowing "fluent" like uniform updates
  19198. */
  19199. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19200. /**
  19201. * Set a vec4 in the shader from a Color4.
  19202. * @param name Define the name of the uniform as defined in the shader
  19203. * @param value Define the value to give to the uniform
  19204. * @return the material itself allowing "fluent" like uniform updates
  19205. */
  19206. setColor4(name: string, value: Color4): ShaderMaterial;
  19207. /**
  19208. * Set a vec4 array in the shader from a Color4 array.
  19209. * @param name Define the name of the uniform as defined in the shader
  19210. * @param value Define the value to give to the uniform
  19211. * @return the material itself allowing "fluent" like uniform updates
  19212. */
  19213. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19214. /**
  19215. * Set a vec2 in the shader from a Vector2.
  19216. * @param name Define the name of the uniform as defined in the shader
  19217. * @param value Define the value to give to the uniform
  19218. * @return the material itself allowing "fluent" like uniform updates
  19219. */
  19220. setVector2(name: string, value: Vector2): ShaderMaterial;
  19221. /**
  19222. * Set a vec3 in the shader from a Vector3.
  19223. * @param name Define the name of the uniform as defined in the shader
  19224. * @param value Define the value to give to the uniform
  19225. * @return the material itself allowing "fluent" like uniform updates
  19226. */
  19227. setVector3(name: string, value: Vector3): ShaderMaterial;
  19228. /**
  19229. * Set a vec4 in the shader from a Vector4.
  19230. * @param name Define the name of the uniform as defined in the shader
  19231. * @param value Define the value to give to the uniform
  19232. * @return the material itself allowing "fluent" like uniform updates
  19233. */
  19234. setVector4(name: string, value: Vector4): ShaderMaterial;
  19235. /**
  19236. * Set a mat4 in the shader from a Matrix.
  19237. * @param name Define the name of the uniform as defined in the shader
  19238. * @param value Define the value to give to the uniform
  19239. * @return the material itself allowing "fluent" like uniform updates
  19240. */
  19241. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19242. /**
  19243. * Set a mat3 in the shader from a Float32Array.
  19244. * @param name Define the name of the uniform as defined in the shader
  19245. * @param value Define the value to give to the uniform
  19246. * @return the material itself allowing "fluent" like uniform updates
  19247. */
  19248. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19249. /**
  19250. * Set a mat2 in the shader from a Float32Array.
  19251. * @param name Define the name of the uniform as defined in the shader
  19252. * @param value Define the value to give to the uniform
  19253. * @return the material itself allowing "fluent" like uniform updates
  19254. */
  19255. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19256. /**
  19257. * Set a vec2 array in the shader from a number array.
  19258. * @param name Define the name of the uniform as defined in the shader
  19259. * @param value Define the value to give to the uniform
  19260. * @return the material itself allowing "fluent" like uniform updates
  19261. */
  19262. setArray2(name: string, value: number[]): ShaderMaterial;
  19263. /**
  19264. * Set a vec3 array in the shader from a number array.
  19265. * @param name Define the name of the uniform as defined in the shader
  19266. * @param value Define the value to give to the uniform
  19267. * @return the material itself allowing "fluent" like uniform updates
  19268. */
  19269. setArray3(name: string, value: number[]): ShaderMaterial;
  19270. /**
  19271. * Set a vec4 array in the shader from a number array.
  19272. * @param name Define the name of the uniform as defined in the shader
  19273. * @param value Define the value to give to the uniform
  19274. * @return the material itself allowing "fluent" like uniform updates
  19275. */
  19276. setArray4(name: string, value: number[]): ShaderMaterial;
  19277. private _checkCache;
  19278. /**
  19279. * Specifies that the submesh is ready to be used
  19280. * @param mesh defines the mesh to check
  19281. * @param subMesh defines which submesh to check
  19282. * @param useInstances specifies that instances should be used
  19283. * @returns a boolean indicating that the submesh is ready or not
  19284. */
  19285. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19286. /**
  19287. * Checks if the material is ready to render the requested mesh
  19288. * @param mesh Define the mesh to render
  19289. * @param useInstances Define whether or not the material is used with instances
  19290. * @returns true if ready, otherwise false
  19291. */
  19292. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19293. /**
  19294. * Binds the world matrix to the material
  19295. * @param world defines the world transformation matrix
  19296. */
  19297. bindOnlyWorldMatrix(world: Matrix): void;
  19298. /**
  19299. * Binds the material to the mesh
  19300. * @param world defines the world transformation matrix
  19301. * @param mesh defines the mesh to bind the material to
  19302. */
  19303. bind(world: Matrix, mesh?: Mesh): void;
  19304. /**
  19305. * Gets the active textures from the material
  19306. * @returns an array of textures
  19307. */
  19308. getActiveTextures(): BaseTexture[];
  19309. /**
  19310. * Specifies if the material uses a texture
  19311. * @param texture defines the texture to check against the material
  19312. * @returns a boolean specifying if the material uses the texture
  19313. */
  19314. hasTexture(texture: BaseTexture): boolean;
  19315. /**
  19316. * Makes a duplicate of the material, and gives it a new name
  19317. * @param name defines the new name for the duplicated material
  19318. * @returns the cloned material
  19319. */
  19320. clone(name: string): ShaderMaterial;
  19321. /**
  19322. * Disposes the material
  19323. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19324. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19325. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19326. */
  19327. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19328. /**
  19329. * Serializes this material in a JSON representation
  19330. * @returns the serialized material object
  19331. */
  19332. serialize(): any;
  19333. /**
  19334. * Creates a shader material from parsed shader material data
  19335. * @param source defines the JSON represnetation of the material
  19336. * @param scene defines the hosting scene
  19337. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19338. * @returns a new material
  19339. */
  19340. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19341. }
  19342. }
  19343. declare module BABYLON {
  19344. /** @hidden */
  19345. export var colorPixelShader: {
  19346. name: string;
  19347. shader: string;
  19348. };
  19349. }
  19350. declare module BABYLON {
  19351. /** @hidden */
  19352. export var colorVertexShader: {
  19353. name: string;
  19354. shader: string;
  19355. };
  19356. }
  19357. declare module BABYLON {
  19358. /**
  19359. * Line mesh
  19360. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19361. */
  19362. export class LinesMesh extends Mesh {
  19363. /**
  19364. * If vertex color should be applied to the mesh
  19365. */
  19366. readonly useVertexColor?: boolean | undefined;
  19367. /**
  19368. * If vertex alpha should be applied to the mesh
  19369. */
  19370. readonly useVertexAlpha?: boolean | undefined;
  19371. /**
  19372. * Color of the line (Default: White)
  19373. */
  19374. color: Color3;
  19375. /**
  19376. * Alpha of the line (Default: 1)
  19377. */
  19378. alpha: number;
  19379. /**
  19380. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19381. * This margin is expressed in world space coordinates, so its value may vary.
  19382. * Default value is 0.1
  19383. */
  19384. intersectionThreshold: number;
  19385. private _colorShader;
  19386. private color4;
  19387. /**
  19388. * Creates a new LinesMesh
  19389. * @param name defines the name
  19390. * @param scene defines the hosting scene
  19391. * @param parent defines the parent mesh if any
  19392. * @param source defines the optional source LinesMesh used to clone data from
  19393. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19394. * When false, achieved by calling a clone(), also passing False.
  19395. * This will make creation of children, recursive.
  19396. * @param useVertexColor defines if this LinesMesh supports vertex color
  19397. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19398. */
  19399. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19400. /**
  19401. * If vertex color should be applied to the mesh
  19402. */
  19403. useVertexColor?: boolean | undefined,
  19404. /**
  19405. * If vertex alpha should be applied to the mesh
  19406. */
  19407. useVertexAlpha?: boolean | undefined);
  19408. private _addClipPlaneDefine;
  19409. private _removeClipPlaneDefine;
  19410. isReady(): boolean;
  19411. /**
  19412. * Returns the string "LineMesh"
  19413. */
  19414. getClassName(): string;
  19415. /**
  19416. * @hidden
  19417. */
  19418. /**
  19419. * @hidden
  19420. */
  19421. material: Material;
  19422. /**
  19423. * @hidden
  19424. */
  19425. readonly checkCollisions: boolean;
  19426. /** @hidden */
  19427. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19428. /** @hidden */
  19429. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19430. /**
  19431. * Disposes of the line mesh
  19432. * @param doNotRecurse If children should be disposed
  19433. */
  19434. dispose(doNotRecurse?: boolean): void;
  19435. /**
  19436. * Returns a new LineMesh object cloned from the current one.
  19437. */
  19438. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19439. /**
  19440. * Creates a new InstancedLinesMesh object from the mesh model.
  19441. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19442. * @param name defines the name of the new instance
  19443. * @returns a new InstancedLinesMesh
  19444. */
  19445. createInstance(name: string): InstancedLinesMesh;
  19446. }
  19447. /**
  19448. * Creates an instance based on a source LinesMesh
  19449. */
  19450. export class InstancedLinesMesh extends InstancedMesh {
  19451. /**
  19452. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19453. * This margin is expressed in world space coordinates, so its value may vary.
  19454. * Initilized with the intersectionThreshold value of the source LinesMesh
  19455. */
  19456. intersectionThreshold: number;
  19457. constructor(name: string, source: LinesMesh);
  19458. /**
  19459. * Returns the string "InstancedLinesMesh".
  19460. */
  19461. getClassName(): string;
  19462. }
  19463. }
  19464. declare module BABYLON {
  19465. /** @hidden */
  19466. export var linePixelShader: {
  19467. name: string;
  19468. shader: string;
  19469. };
  19470. }
  19471. declare module BABYLON {
  19472. /** @hidden */
  19473. export var lineVertexShader: {
  19474. name: string;
  19475. shader: string;
  19476. };
  19477. }
  19478. declare module BABYLON {
  19479. interface AbstractMesh {
  19480. /**
  19481. * Gets the edgesRenderer associated with the mesh
  19482. */
  19483. edgesRenderer: Nullable<EdgesRenderer>;
  19484. }
  19485. interface LinesMesh {
  19486. /**
  19487. * Enables the edge rendering mode on the mesh.
  19488. * This mode makes the mesh edges visible
  19489. * @param epsilon defines the maximal distance between two angles to detect a face
  19490. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19491. * @returns the currentAbstractMesh
  19492. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19493. */
  19494. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19495. }
  19496. interface InstancedLinesMesh {
  19497. /**
  19498. * Enables the edge rendering mode on the mesh.
  19499. * This mode makes the mesh edges visible
  19500. * @param epsilon defines the maximal distance between two angles to detect a face
  19501. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19502. * @returns the current InstancedLinesMesh
  19503. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19504. */
  19505. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19506. }
  19507. /**
  19508. * Defines the minimum contract an Edges renderer should follow.
  19509. */
  19510. export interface IEdgesRenderer extends IDisposable {
  19511. /**
  19512. * Gets or sets a boolean indicating if the edgesRenderer is active
  19513. */
  19514. isEnabled: boolean;
  19515. /**
  19516. * Renders the edges of the attached mesh,
  19517. */
  19518. render(): void;
  19519. /**
  19520. * Checks wether or not the edges renderer is ready to render.
  19521. * @return true if ready, otherwise false.
  19522. */
  19523. isReady(): boolean;
  19524. }
  19525. /**
  19526. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19527. */
  19528. export class EdgesRenderer implements IEdgesRenderer {
  19529. /**
  19530. * Define the size of the edges with an orthographic camera
  19531. */
  19532. edgesWidthScalerForOrthographic: number;
  19533. /**
  19534. * Define the size of the edges with a perspective camera
  19535. */
  19536. edgesWidthScalerForPerspective: number;
  19537. protected _source: AbstractMesh;
  19538. protected _linesPositions: number[];
  19539. protected _linesNormals: number[];
  19540. protected _linesIndices: number[];
  19541. protected _epsilon: number;
  19542. protected _indicesCount: number;
  19543. protected _lineShader: ShaderMaterial;
  19544. protected _ib: DataBuffer;
  19545. protected _buffers: {
  19546. [key: string]: Nullable<VertexBuffer>;
  19547. };
  19548. protected _checkVerticesInsteadOfIndices: boolean;
  19549. private _meshRebuildObserver;
  19550. private _meshDisposeObserver;
  19551. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19552. isEnabled: boolean;
  19553. /**
  19554. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19555. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19556. * @param source Mesh used to create edges
  19557. * @param epsilon sum of angles in adjacency to check for edge
  19558. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19559. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19560. */
  19561. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19562. protected _prepareRessources(): void;
  19563. /** @hidden */
  19564. _rebuild(): void;
  19565. /**
  19566. * Releases the required resources for the edges renderer
  19567. */
  19568. dispose(): void;
  19569. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19570. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19571. /**
  19572. * Checks if the pair of p0 and p1 is en edge
  19573. * @param faceIndex
  19574. * @param edge
  19575. * @param faceNormals
  19576. * @param p0
  19577. * @param p1
  19578. * @private
  19579. */
  19580. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19581. /**
  19582. * push line into the position, normal and index buffer
  19583. * @protected
  19584. */
  19585. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19586. /**
  19587. * Generates lines edges from adjacencjes
  19588. * @private
  19589. */
  19590. _generateEdgesLines(): void;
  19591. /**
  19592. * Checks wether or not the edges renderer is ready to render.
  19593. * @return true if ready, otherwise false.
  19594. */
  19595. isReady(): boolean;
  19596. /**
  19597. * Renders the edges of the attached mesh,
  19598. */
  19599. render(): void;
  19600. }
  19601. /**
  19602. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19603. */
  19604. export class LineEdgesRenderer extends EdgesRenderer {
  19605. /**
  19606. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19607. * @param source LineMesh used to generate edges
  19608. * @param epsilon not important (specified angle for edge detection)
  19609. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19610. */
  19611. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19612. /**
  19613. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19614. */
  19615. _generateEdgesLines(): void;
  19616. }
  19617. }
  19618. declare module BABYLON {
  19619. /**
  19620. * This represents the object necessary to create a rendering group.
  19621. * This is exclusively used and created by the rendering manager.
  19622. * To modify the behavior, you use the available helpers in your scene or meshes.
  19623. * @hidden
  19624. */
  19625. export class RenderingGroup {
  19626. index: number;
  19627. private static _zeroVector;
  19628. private _scene;
  19629. private _opaqueSubMeshes;
  19630. private _transparentSubMeshes;
  19631. private _alphaTestSubMeshes;
  19632. private _depthOnlySubMeshes;
  19633. private _particleSystems;
  19634. private _spriteManagers;
  19635. private _opaqueSortCompareFn;
  19636. private _alphaTestSortCompareFn;
  19637. private _transparentSortCompareFn;
  19638. private _renderOpaque;
  19639. private _renderAlphaTest;
  19640. private _renderTransparent;
  19641. /** @hidden */
  19642. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19643. onBeforeTransparentRendering: () => void;
  19644. /**
  19645. * Set the opaque sort comparison function.
  19646. * If null the sub meshes will be render in the order they were created
  19647. */
  19648. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19649. /**
  19650. * Set the alpha test sort comparison function.
  19651. * If null the sub meshes will be render in the order they were created
  19652. */
  19653. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19654. /**
  19655. * Set the transparent sort comparison function.
  19656. * If null the sub meshes will be render in the order they were created
  19657. */
  19658. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19659. /**
  19660. * Creates a new rendering group.
  19661. * @param index The rendering group index
  19662. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19663. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19664. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19665. */
  19666. 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>);
  19667. /**
  19668. * Render all the sub meshes contained in the group.
  19669. * @param customRenderFunction Used to override the default render behaviour of the group.
  19670. * @returns true if rendered some submeshes.
  19671. */
  19672. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19673. /**
  19674. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19675. * @param subMeshes The submeshes to render
  19676. */
  19677. private renderOpaqueSorted;
  19678. /**
  19679. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19680. * @param subMeshes The submeshes to render
  19681. */
  19682. private renderAlphaTestSorted;
  19683. /**
  19684. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19685. * @param subMeshes The submeshes to render
  19686. */
  19687. private renderTransparentSorted;
  19688. /**
  19689. * Renders the submeshes in a specified order.
  19690. * @param subMeshes The submeshes to sort before render
  19691. * @param sortCompareFn The comparison function use to sort
  19692. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19693. * @param transparent Specifies to activate blending if true
  19694. */
  19695. private static renderSorted;
  19696. /**
  19697. * Renders the submeshes in the order they were dispatched (no sort applied).
  19698. * @param subMeshes The submeshes to render
  19699. */
  19700. private static renderUnsorted;
  19701. /**
  19702. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19703. * are rendered back to front if in the same alpha index.
  19704. *
  19705. * @param a The first submesh
  19706. * @param b The second submesh
  19707. * @returns The result of the comparison
  19708. */
  19709. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19710. /**
  19711. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19712. * are rendered back to front.
  19713. *
  19714. * @param a The first submesh
  19715. * @param b The second submesh
  19716. * @returns The result of the comparison
  19717. */
  19718. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19719. /**
  19720. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19721. * are rendered front to back (prevent overdraw).
  19722. *
  19723. * @param a The first submesh
  19724. * @param b The second submesh
  19725. * @returns The result of the comparison
  19726. */
  19727. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19728. /**
  19729. * Resets the different lists of submeshes to prepare a new frame.
  19730. */
  19731. prepare(): void;
  19732. dispose(): void;
  19733. /**
  19734. * Inserts the submesh in its correct queue depending on its material.
  19735. * @param subMesh The submesh to dispatch
  19736. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19737. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19738. */
  19739. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19740. dispatchSprites(spriteManager: ISpriteManager): void;
  19741. dispatchParticles(particleSystem: IParticleSystem): void;
  19742. private _renderParticles;
  19743. private _renderSprites;
  19744. }
  19745. }
  19746. declare module BABYLON {
  19747. /**
  19748. * Interface describing the different options available in the rendering manager
  19749. * regarding Auto Clear between groups.
  19750. */
  19751. export interface IRenderingManagerAutoClearSetup {
  19752. /**
  19753. * Defines whether or not autoclear is enable.
  19754. */
  19755. autoClear: boolean;
  19756. /**
  19757. * Defines whether or not to autoclear the depth buffer.
  19758. */
  19759. depth: boolean;
  19760. /**
  19761. * Defines whether or not to autoclear the stencil buffer.
  19762. */
  19763. stencil: boolean;
  19764. }
  19765. /**
  19766. * This class is used by the onRenderingGroupObservable
  19767. */
  19768. export class RenderingGroupInfo {
  19769. /**
  19770. * The Scene that being rendered
  19771. */
  19772. scene: Scene;
  19773. /**
  19774. * The camera currently used for the rendering pass
  19775. */
  19776. camera: Nullable<Camera>;
  19777. /**
  19778. * The ID of the renderingGroup being processed
  19779. */
  19780. renderingGroupId: number;
  19781. }
  19782. /**
  19783. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19784. * It is enable to manage the different groups as well as the different necessary sort functions.
  19785. * This should not be used directly aside of the few static configurations
  19786. */
  19787. export class RenderingManager {
  19788. /**
  19789. * The max id used for rendering groups (not included)
  19790. */
  19791. static MAX_RENDERINGGROUPS: number;
  19792. /**
  19793. * The min id used for rendering groups (included)
  19794. */
  19795. static MIN_RENDERINGGROUPS: number;
  19796. /**
  19797. * Used to globally prevent autoclearing scenes.
  19798. */
  19799. static AUTOCLEAR: boolean;
  19800. /**
  19801. * @hidden
  19802. */
  19803. _useSceneAutoClearSetup: boolean;
  19804. private _scene;
  19805. private _renderingGroups;
  19806. private _depthStencilBufferAlreadyCleaned;
  19807. private _autoClearDepthStencil;
  19808. private _customOpaqueSortCompareFn;
  19809. private _customAlphaTestSortCompareFn;
  19810. private _customTransparentSortCompareFn;
  19811. private _renderingGroupInfo;
  19812. /**
  19813. * Instantiates a new rendering group for a particular scene
  19814. * @param scene Defines the scene the groups belongs to
  19815. */
  19816. constructor(scene: Scene);
  19817. private _clearDepthStencilBuffer;
  19818. /**
  19819. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19820. * @hidden
  19821. */
  19822. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19823. /**
  19824. * Resets the different information of the group to prepare a new frame
  19825. * @hidden
  19826. */
  19827. reset(): void;
  19828. /**
  19829. * Dispose and release the group and its associated resources.
  19830. * @hidden
  19831. */
  19832. dispose(): void;
  19833. /**
  19834. * Clear the info related to rendering groups preventing retention points during dispose.
  19835. */
  19836. freeRenderingGroups(): void;
  19837. private _prepareRenderingGroup;
  19838. /**
  19839. * Add a sprite manager to the rendering manager in order to render it this frame.
  19840. * @param spriteManager Define the sprite manager to render
  19841. */
  19842. dispatchSprites(spriteManager: ISpriteManager): void;
  19843. /**
  19844. * Add a particle system to the rendering manager in order to render it this frame.
  19845. * @param particleSystem Define the particle system to render
  19846. */
  19847. dispatchParticles(particleSystem: IParticleSystem): void;
  19848. /**
  19849. * Add a submesh to the manager in order to render it this frame
  19850. * @param subMesh The submesh to dispatch
  19851. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19852. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19853. */
  19854. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19855. /**
  19856. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19857. * This allowed control for front to back rendering or reversly depending of the special needs.
  19858. *
  19859. * @param renderingGroupId The rendering group id corresponding to its index
  19860. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19861. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19862. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19863. */
  19864. 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;
  19865. /**
  19866. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19867. *
  19868. * @param renderingGroupId The rendering group id corresponding to its index
  19869. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19870. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19871. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19872. */
  19873. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19874. /**
  19875. * Gets the current auto clear configuration for one rendering group of the rendering
  19876. * manager.
  19877. * @param index the rendering group index to get the information for
  19878. * @returns The auto clear setup for the requested rendering group
  19879. */
  19880. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19881. }
  19882. }
  19883. declare module BABYLON {
  19884. /**
  19885. * This Helps creating a texture that will be created from a camera in your scene.
  19886. * It is basically a dynamic texture that could be used to create special effects for instance.
  19887. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19888. */
  19889. export class RenderTargetTexture extends Texture {
  19890. isCube: boolean;
  19891. /**
  19892. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19893. */
  19894. static readonly REFRESHRATE_RENDER_ONCE: number;
  19895. /**
  19896. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19897. */
  19898. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19899. /**
  19900. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19901. * the central point of your effect and can save a lot of performances.
  19902. */
  19903. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19904. /**
  19905. * Use this predicate to dynamically define the list of mesh you want to render.
  19906. * If set, the renderList property will be overwritten.
  19907. */
  19908. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19909. private _renderList;
  19910. /**
  19911. * Use this list to define the list of mesh you want to render.
  19912. */
  19913. renderList: Nullable<Array<AbstractMesh>>;
  19914. private _hookArray;
  19915. /**
  19916. * Define if particles should be rendered in your texture.
  19917. */
  19918. renderParticles: boolean;
  19919. /**
  19920. * Define if sprites should be rendered in your texture.
  19921. */
  19922. renderSprites: boolean;
  19923. /**
  19924. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19925. */
  19926. coordinatesMode: number;
  19927. /**
  19928. * Define the camera used to render the texture.
  19929. */
  19930. activeCamera: Nullable<Camera>;
  19931. /**
  19932. * Override the render function of the texture with your own one.
  19933. */
  19934. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19935. /**
  19936. * Define if camera post processes should be use while rendering the texture.
  19937. */
  19938. useCameraPostProcesses: boolean;
  19939. /**
  19940. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19941. */
  19942. ignoreCameraViewport: boolean;
  19943. private _postProcessManager;
  19944. private _postProcesses;
  19945. private _resizeObserver;
  19946. /**
  19947. * An event triggered when the texture is unbind.
  19948. */
  19949. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19950. /**
  19951. * An event triggered when the texture is unbind.
  19952. */
  19953. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19954. private _onAfterUnbindObserver;
  19955. /**
  19956. * Set a after unbind callback in the texture.
  19957. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19958. */
  19959. onAfterUnbind: () => void;
  19960. /**
  19961. * An event triggered before rendering the texture
  19962. */
  19963. onBeforeRenderObservable: Observable<number>;
  19964. private _onBeforeRenderObserver;
  19965. /**
  19966. * Set a before render callback in the texture.
  19967. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19968. */
  19969. onBeforeRender: (faceIndex: number) => void;
  19970. /**
  19971. * An event triggered after rendering the texture
  19972. */
  19973. onAfterRenderObservable: Observable<number>;
  19974. private _onAfterRenderObserver;
  19975. /**
  19976. * Set a after render callback in the texture.
  19977. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19978. */
  19979. onAfterRender: (faceIndex: number) => void;
  19980. /**
  19981. * An event triggered after the texture clear
  19982. */
  19983. onClearObservable: Observable<Engine>;
  19984. private _onClearObserver;
  19985. /**
  19986. * Set a clear callback in the texture.
  19987. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19988. */
  19989. onClear: (Engine: Engine) => void;
  19990. /**
  19991. * An event triggered when the texture is resized.
  19992. */
  19993. onResizeObservable: Observable<RenderTargetTexture>;
  19994. /**
  19995. * Define the clear color of the Render Target if it should be different from the scene.
  19996. */
  19997. clearColor: Color4;
  19998. protected _size: number | {
  19999. width: number;
  20000. height: number;
  20001. };
  20002. protected _initialSizeParameter: number | {
  20003. width: number;
  20004. height: number;
  20005. } | {
  20006. ratio: number;
  20007. };
  20008. protected _sizeRatio: Nullable<number>;
  20009. /** @hidden */
  20010. _generateMipMaps: boolean;
  20011. protected _renderingManager: RenderingManager;
  20012. /** @hidden */
  20013. _waitingRenderList: string[];
  20014. protected _doNotChangeAspectRatio: boolean;
  20015. protected _currentRefreshId: number;
  20016. protected _refreshRate: number;
  20017. protected _textureMatrix: Matrix;
  20018. protected _samples: number;
  20019. protected _renderTargetOptions: RenderTargetCreationOptions;
  20020. /**
  20021. * Gets render target creation options that were used.
  20022. */
  20023. readonly renderTargetOptions: RenderTargetCreationOptions;
  20024. protected _engine: Engine;
  20025. protected _onRatioRescale(): void;
  20026. /**
  20027. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20028. * It must define where the camera used to render the texture is set
  20029. */
  20030. boundingBoxPosition: Vector3;
  20031. private _boundingBoxSize;
  20032. /**
  20033. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20034. * When defined, the cubemap will switch to local mode
  20035. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20036. * @example https://www.babylonjs-playground.com/#RNASML
  20037. */
  20038. boundingBoxSize: Vector3;
  20039. /**
  20040. * In case the RTT has been created with a depth texture, get the associated
  20041. * depth texture.
  20042. * Otherwise, return null.
  20043. */
  20044. depthStencilTexture: Nullable<InternalTexture>;
  20045. /**
  20046. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20047. * or used a shadow, depth texture...
  20048. * @param name The friendly name of the texture
  20049. * @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)
  20050. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20051. * @param generateMipMaps True if mip maps need to be generated after render.
  20052. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20053. * @param type The type of the buffer in the RTT (int, half float, float...)
  20054. * @param isCube True if a cube texture needs to be created
  20055. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20056. * @param generateDepthBuffer True to generate a depth buffer
  20057. * @param generateStencilBuffer True to generate a stencil buffer
  20058. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20059. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20060. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20061. */
  20062. constructor(name: string, size: number | {
  20063. width: number;
  20064. height: number;
  20065. } | {
  20066. ratio: number;
  20067. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20068. /**
  20069. * Creates a depth stencil texture.
  20070. * This is only available in WebGL 2 or with the depth texture extension available.
  20071. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20072. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20073. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20074. */
  20075. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20076. private _processSizeParameter;
  20077. /**
  20078. * Define the number of samples to use in case of MSAA.
  20079. * It defaults to one meaning no MSAA has been enabled.
  20080. */
  20081. samples: number;
  20082. /**
  20083. * Resets the refresh counter of the texture and start bak from scratch.
  20084. * Could be useful to regenerate the texture if it is setup to render only once.
  20085. */
  20086. resetRefreshCounter(): void;
  20087. /**
  20088. * Define the refresh rate of the texture or the rendering frequency.
  20089. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20090. */
  20091. refreshRate: number;
  20092. /**
  20093. * Adds a post process to the render target rendering passes.
  20094. * @param postProcess define the post process to add
  20095. */
  20096. addPostProcess(postProcess: PostProcess): void;
  20097. /**
  20098. * Clear all the post processes attached to the render target
  20099. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20100. */
  20101. clearPostProcesses(dispose?: boolean): void;
  20102. /**
  20103. * Remove one of the post process from the list of attached post processes to the texture
  20104. * @param postProcess define the post process to remove from the list
  20105. */
  20106. removePostProcess(postProcess: PostProcess): void;
  20107. /** @hidden */
  20108. _shouldRender(): boolean;
  20109. /**
  20110. * Gets the actual render size of the texture.
  20111. * @returns the width of the render size
  20112. */
  20113. getRenderSize(): number;
  20114. /**
  20115. * Gets the actual render width of the texture.
  20116. * @returns the width of the render size
  20117. */
  20118. getRenderWidth(): number;
  20119. /**
  20120. * Gets the actual render height of the texture.
  20121. * @returns the height of the render size
  20122. */
  20123. getRenderHeight(): number;
  20124. /**
  20125. * Get if the texture can be rescaled or not.
  20126. */
  20127. readonly canRescale: boolean;
  20128. /**
  20129. * Resize the texture using a ratio.
  20130. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20131. */
  20132. scale(ratio: number): void;
  20133. /**
  20134. * Get the texture reflection matrix used to rotate/transform the reflection.
  20135. * @returns the reflection matrix
  20136. */
  20137. getReflectionTextureMatrix(): Matrix;
  20138. /**
  20139. * Resize the texture to a new desired size.
  20140. * Be carrefull as it will recreate all the data in the new texture.
  20141. * @param size Define the new size. It can be:
  20142. * - a number for squared texture,
  20143. * - an object containing { width: number, height: number }
  20144. * - or an object containing a ratio { ratio: number }
  20145. */
  20146. resize(size: number | {
  20147. width: number;
  20148. height: number;
  20149. } | {
  20150. ratio: number;
  20151. }): void;
  20152. /**
  20153. * Renders all the objects from the render list into the texture.
  20154. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20155. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20156. */
  20157. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20158. private _bestReflectionRenderTargetDimension;
  20159. /**
  20160. * @hidden
  20161. * @param faceIndex face index to bind to if this is a cubetexture
  20162. */
  20163. _bindFrameBuffer(faceIndex?: number): void;
  20164. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20165. private renderToTarget;
  20166. /**
  20167. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20168. * This allowed control for front to back rendering or reversly depending of the special needs.
  20169. *
  20170. * @param renderingGroupId The rendering group id corresponding to its index
  20171. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20172. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20173. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20174. */
  20175. 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;
  20176. /**
  20177. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20178. *
  20179. * @param renderingGroupId The rendering group id corresponding to its index
  20180. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20181. */
  20182. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20183. /**
  20184. * Clones the texture.
  20185. * @returns the cloned texture
  20186. */
  20187. clone(): RenderTargetTexture;
  20188. /**
  20189. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20190. * @returns The JSON representation of the texture
  20191. */
  20192. serialize(): any;
  20193. /**
  20194. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20195. */
  20196. disposeFramebufferObjects(): void;
  20197. /**
  20198. * Dispose the texture and release its associated resources.
  20199. */
  20200. dispose(): void;
  20201. /** @hidden */
  20202. _rebuild(): void;
  20203. /**
  20204. * Clear the info related to rendering groups preventing retention point in material dispose.
  20205. */
  20206. freeRenderingGroups(): void;
  20207. /**
  20208. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20209. * @returns the view count
  20210. */
  20211. getViewCount(): number;
  20212. }
  20213. }
  20214. declare module BABYLON {
  20215. /**
  20216. * Base class for the main features of a material in Babylon.js
  20217. */
  20218. export class Material implements IAnimatable {
  20219. /**
  20220. * Returns the triangle fill mode
  20221. */
  20222. static readonly TriangleFillMode: number;
  20223. /**
  20224. * Returns the wireframe mode
  20225. */
  20226. static readonly WireFrameFillMode: number;
  20227. /**
  20228. * Returns the point fill mode
  20229. */
  20230. static readonly PointFillMode: number;
  20231. /**
  20232. * Returns the point list draw mode
  20233. */
  20234. static readonly PointListDrawMode: number;
  20235. /**
  20236. * Returns the line list draw mode
  20237. */
  20238. static readonly LineListDrawMode: number;
  20239. /**
  20240. * Returns the line loop draw mode
  20241. */
  20242. static readonly LineLoopDrawMode: number;
  20243. /**
  20244. * Returns the line strip draw mode
  20245. */
  20246. static readonly LineStripDrawMode: number;
  20247. /**
  20248. * Returns the triangle strip draw mode
  20249. */
  20250. static readonly TriangleStripDrawMode: number;
  20251. /**
  20252. * Returns the triangle fan draw mode
  20253. */
  20254. static readonly TriangleFanDrawMode: number;
  20255. /**
  20256. * Stores the clock-wise side orientation
  20257. */
  20258. static readonly ClockWiseSideOrientation: number;
  20259. /**
  20260. * Stores the counter clock-wise side orientation
  20261. */
  20262. static readonly CounterClockWiseSideOrientation: number;
  20263. /**
  20264. * The dirty texture flag value
  20265. */
  20266. static readonly TextureDirtyFlag: number;
  20267. /**
  20268. * The dirty light flag value
  20269. */
  20270. static readonly LightDirtyFlag: number;
  20271. /**
  20272. * The dirty fresnel flag value
  20273. */
  20274. static readonly FresnelDirtyFlag: number;
  20275. /**
  20276. * The dirty attribute flag value
  20277. */
  20278. static readonly AttributesDirtyFlag: number;
  20279. /**
  20280. * The dirty misc flag value
  20281. */
  20282. static readonly MiscDirtyFlag: number;
  20283. /**
  20284. * The all dirty flag value
  20285. */
  20286. static readonly AllDirtyFlag: number;
  20287. /**
  20288. * The ID of the material
  20289. */
  20290. id: string;
  20291. /**
  20292. * Gets or sets the unique id of the material
  20293. */
  20294. uniqueId: number;
  20295. /**
  20296. * The name of the material
  20297. */
  20298. name: string;
  20299. /**
  20300. * Gets or sets user defined metadata
  20301. */
  20302. metadata: any;
  20303. /**
  20304. * For internal use only. Please do not use.
  20305. */
  20306. reservedDataStore: any;
  20307. /**
  20308. * Specifies if the ready state should be checked on each call
  20309. */
  20310. checkReadyOnEveryCall: boolean;
  20311. /**
  20312. * Specifies if the ready state should be checked once
  20313. */
  20314. checkReadyOnlyOnce: boolean;
  20315. /**
  20316. * The state of the material
  20317. */
  20318. state: string;
  20319. /**
  20320. * The alpha value of the material
  20321. */
  20322. protected _alpha: number;
  20323. /**
  20324. * List of inspectable custom properties (used by the Inspector)
  20325. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20326. */
  20327. inspectableCustomProperties: IInspectable[];
  20328. /**
  20329. * Sets the alpha value of the material
  20330. */
  20331. /**
  20332. * Gets the alpha value of the material
  20333. */
  20334. alpha: number;
  20335. /**
  20336. * Specifies if back face culling is enabled
  20337. */
  20338. protected _backFaceCulling: boolean;
  20339. /**
  20340. * Sets the back-face culling state
  20341. */
  20342. /**
  20343. * Gets the back-face culling state
  20344. */
  20345. backFaceCulling: boolean;
  20346. /**
  20347. * Stores the value for side orientation
  20348. */
  20349. sideOrientation: number;
  20350. /**
  20351. * Callback triggered when the material is compiled
  20352. */
  20353. onCompiled: Nullable<(effect: Effect) => void>;
  20354. /**
  20355. * Callback triggered when an error occurs
  20356. */
  20357. onError: Nullable<(effect: Effect, errors: string) => void>;
  20358. /**
  20359. * Callback triggered to get the render target textures
  20360. */
  20361. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20362. /**
  20363. * Gets a boolean indicating that current material needs to register RTT
  20364. */
  20365. readonly hasRenderTargetTextures: boolean;
  20366. /**
  20367. * Specifies if the material should be serialized
  20368. */
  20369. doNotSerialize: boolean;
  20370. /**
  20371. * @hidden
  20372. */
  20373. _storeEffectOnSubMeshes: boolean;
  20374. /**
  20375. * Stores the animations for the material
  20376. */
  20377. animations: Nullable<Array<Animation>>;
  20378. /**
  20379. * An event triggered when the material is disposed
  20380. */
  20381. onDisposeObservable: Observable<Material>;
  20382. /**
  20383. * An observer which watches for dispose events
  20384. */
  20385. private _onDisposeObserver;
  20386. private _onUnBindObservable;
  20387. /**
  20388. * Called during a dispose event
  20389. */
  20390. onDispose: () => void;
  20391. private _onBindObservable;
  20392. /**
  20393. * An event triggered when the material is bound
  20394. */
  20395. readonly onBindObservable: Observable<AbstractMesh>;
  20396. /**
  20397. * An observer which watches for bind events
  20398. */
  20399. private _onBindObserver;
  20400. /**
  20401. * Called during a bind event
  20402. */
  20403. onBind: (Mesh: AbstractMesh) => void;
  20404. /**
  20405. * An event triggered when the material is unbound
  20406. */
  20407. readonly onUnBindObservable: Observable<Material>;
  20408. /**
  20409. * Stores the value of the alpha mode
  20410. */
  20411. private _alphaMode;
  20412. /**
  20413. * Sets the value of the alpha mode.
  20414. *
  20415. * | Value | Type | Description |
  20416. * | --- | --- | --- |
  20417. * | 0 | ALPHA_DISABLE | |
  20418. * | 1 | ALPHA_ADD | |
  20419. * | 2 | ALPHA_COMBINE | |
  20420. * | 3 | ALPHA_SUBTRACT | |
  20421. * | 4 | ALPHA_MULTIPLY | |
  20422. * | 5 | ALPHA_MAXIMIZED | |
  20423. * | 6 | ALPHA_ONEONE | |
  20424. * | 7 | ALPHA_PREMULTIPLIED | |
  20425. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20426. * | 9 | ALPHA_INTERPOLATE | |
  20427. * | 10 | ALPHA_SCREENMODE | |
  20428. *
  20429. */
  20430. /**
  20431. * Gets the value of the alpha mode
  20432. */
  20433. alphaMode: number;
  20434. /**
  20435. * Stores the state of the need depth pre-pass value
  20436. */
  20437. private _needDepthPrePass;
  20438. /**
  20439. * Sets the need depth pre-pass value
  20440. */
  20441. /**
  20442. * Gets the depth pre-pass value
  20443. */
  20444. needDepthPrePass: boolean;
  20445. /**
  20446. * Specifies if depth writing should be disabled
  20447. */
  20448. disableDepthWrite: boolean;
  20449. /**
  20450. * Specifies if depth writing should be forced
  20451. */
  20452. forceDepthWrite: boolean;
  20453. /**
  20454. * Specifies if there should be a separate pass for culling
  20455. */
  20456. separateCullingPass: boolean;
  20457. /**
  20458. * Stores the state specifing if fog should be enabled
  20459. */
  20460. private _fogEnabled;
  20461. /**
  20462. * Sets the state for enabling fog
  20463. */
  20464. /**
  20465. * Gets the value of the fog enabled state
  20466. */
  20467. fogEnabled: boolean;
  20468. /**
  20469. * Stores the size of points
  20470. */
  20471. pointSize: number;
  20472. /**
  20473. * Stores the z offset value
  20474. */
  20475. zOffset: number;
  20476. /**
  20477. * Gets a value specifying if wireframe mode is enabled
  20478. */
  20479. /**
  20480. * Sets the state of wireframe mode
  20481. */
  20482. wireframe: boolean;
  20483. /**
  20484. * Gets the value specifying if point clouds are enabled
  20485. */
  20486. /**
  20487. * Sets the state of point cloud mode
  20488. */
  20489. pointsCloud: boolean;
  20490. /**
  20491. * Gets the material fill mode
  20492. */
  20493. /**
  20494. * Sets the material fill mode
  20495. */
  20496. fillMode: number;
  20497. /**
  20498. * @hidden
  20499. * Stores the effects for the material
  20500. */
  20501. _effect: Nullable<Effect>;
  20502. /**
  20503. * @hidden
  20504. * Specifies if the material was previously ready
  20505. */
  20506. _wasPreviouslyReady: boolean;
  20507. /**
  20508. * Specifies if uniform buffers should be used
  20509. */
  20510. private _useUBO;
  20511. /**
  20512. * Stores a reference to the scene
  20513. */
  20514. private _scene;
  20515. /**
  20516. * Stores the fill mode state
  20517. */
  20518. private _fillMode;
  20519. /**
  20520. * Specifies if the depth write state should be cached
  20521. */
  20522. private _cachedDepthWriteState;
  20523. /**
  20524. * Stores the uniform buffer
  20525. */
  20526. protected _uniformBuffer: UniformBuffer;
  20527. /** @hidden */
  20528. _indexInSceneMaterialArray: number;
  20529. /** @hidden */
  20530. meshMap: Nullable<{
  20531. [id: string]: AbstractMesh | undefined;
  20532. }>;
  20533. /**
  20534. * Creates a material instance
  20535. * @param name defines the name of the material
  20536. * @param scene defines the scene to reference
  20537. * @param doNotAdd specifies if the material should be added to the scene
  20538. */
  20539. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20540. /**
  20541. * Returns a string representation of the current material
  20542. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20543. * @returns a string with material information
  20544. */
  20545. toString(fullDetails?: boolean): string;
  20546. /**
  20547. * Gets the class name of the material
  20548. * @returns a string with the class name of the material
  20549. */
  20550. getClassName(): string;
  20551. /**
  20552. * Specifies if updates for the material been locked
  20553. */
  20554. readonly isFrozen: boolean;
  20555. /**
  20556. * Locks updates for the material
  20557. */
  20558. freeze(): void;
  20559. /**
  20560. * Unlocks updates for the material
  20561. */
  20562. unfreeze(): void;
  20563. /**
  20564. * Specifies if the material is ready to be used
  20565. * @param mesh defines the mesh to check
  20566. * @param useInstances specifies if instances should be used
  20567. * @returns a boolean indicating if the material is ready to be used
  20568. */
  20569. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20570. /**
  20571. * Specifies that the submesh is ready to be used
  20572. * @param mesh defines the mesh to check
  20573. * @param subMesh defines which submesh to check
  20574. * @param useInstances specifies that instances should be used
  20575. * @returns a boolean indicating that the submesh is ready or not
  20576. */
  20577. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20578. /**
  20579. * Returns the material effect
  20580. * @returns the effect associated with the material
  20581. */
  20582. getEffect(): Nullable<Effect>;
  20583. /**
  20584. * Returns the current scene
  20585. * @returns a Scene
  20586. */
  20587. getScene(): Scene;
  20588. /**
  20589. * Specifies if the material will require alpha blending
  20590. * @returns a boolean specifying if alpha blending is needed
  20591. */
  20592. needAlphaBlending(): boolean;
  20593. /**
  20594. * Specifies if the mesh will require alpha blending
  20595. * @param mesh defines the mesh to check
  20596. * @returns a boolean specifying if alpha blending is needed for the mesh
  20597. */
  20598. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20599. /**
  20600. * Specifies if this material should be rendered in alpha test mode
  20601. * @returns a boolean specifying if an alpha test is needed.
  20602. */
  20603. needAlphaTesting(): boolean;
  20604. /**
  20605. * Gets the texture used for the alpha test
  20606. * @returns the texture to use for alpha testing
  20607. */
  20608. getAlphaTestTexture(): Nullable<BaseTexture>;
  20609. /**
  20610. * Marks the material to indicate that it needs to be re-calculated
  20611. */
  20612. markDirty(): void;
  20613. /** @hidden */
  20614. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20615. /**
  20616. * Binds the material to the mesh
  20617. * @param world defines the world transformation matrix
  20618. * @param mesh defines the mesh to bind the material to
  20619. */
  20620. bind(world: Matrix, mesh?: Mesh): void;
  20621. /**
  20622. * Binds the submesh to the material
  20623. * @param world defines the world transformation matrix
  20624. * @param mesh defines the mesh containing the submesh
  20625. * @param subMesh defines the submesh to bind the material to
  20626. */
  20627. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20628. /**
  20629. * Binds the world matrix to the material
  20630. * @param world defines the world transformation matrix
  20631. */
  20632. bindOnlyWorldMatrix(world: Matrix): void;
  20633. /**
  20634. * Binds the scene's uniform buffer to the effect.
  20635. * @param effect defines the effect to bind to the scene uniform buffer
  20636. * @param sceneUbo defines the uniform buffer storing scene data
  20637. */
  20638. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20639. /**
  20640. * Binds the view matrix to the effect
  20641. * @param effect defines the effect to bind the view matrix to
  20642. */
  20643. bindView(effect: Effect): void;
  20644. /**
  20645. * Binds the view projection matrix to the effect
  20646. * @param effect defines the effect to bind the view projection matrix to
  20647. */
  20648. bindViewProjection(effect: Effect): void;
  20649. /**
  20650. * Specifies if material alpha testing should be turned on for the mesh
  20651. * @param mesh defines the mesh to check
  20652. */
  20653. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20654. /**
  20655. * Processes to execute after binding the material to a mesh
  20656. * @param mesh defines the rendered mesh
  20657. */
  20658. protected _afterBind(mesh?: Mesh): void;
  20659. /**
  20660. * Unbinds the material from the mesh
  20661. */
  20662. unbind(): void;
  20663. /**
  20664. * Gets the active textures from the material
  20665. * @returns an array of textures
  20666. */
  20667. getActiveTextures(): BaseTexture[];
  20668. /**
  20669. * Specifies if the material uses a texture
  20670. * @param texture defines the texture to check against the material
  20671. * @returns a boolean specifying if the material uses the texture
  20672. */
  20673. hasTexture(texture: BaseTexture): boolean;
  20674. /**
  20675. * Makes a duplicate of the material, and gives it a new name
  20676. * @param name defines the new name for the duplicated material
  20677. * @returns the cloned material
  20678. */
  20679. clone(name: string): Nullable<Material>;
  20680. /**
  20681. * Gets the meshes bound to the material
  20682. * @returns an array of meshes bound to the material
  20683. */
  20684. getBindedMeshes(): AbstractMesh[];
  20685. /**
  20686. * Force shader compilation
  20687. * @param mesh defines the mesh associated with this material
  20688. * @param onCompiled defines a function to execute once the material is compiled
  20689. * @param options defines the options to configure the compilation
  20690. */
  20691. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20692. clipPlane: boolean;
  20693. }>): void;
  20694. /**
  20695. * Force shader compilation
  20696. * @param mesh defines the mesh that will use this material
  20697. * @param options defines additional options for compiling the shaders
  20698. * @returns a promise that resolves when the compilation completes
  20699. */
  20700. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20701. clipPlane: boolean;
  20702. }>): Promise<void>;
  20703. private static readonly _AllDirtyCallBack;
  20704. private static readonly _ImageProcessingDirtyCallBack;
  20705. private static readonly _TextureDirtyCallBack;
  20706. private static readonly _FresnelDirtyCallBack;
  20707. private static readonly _MiscDirtyCallBack;
  20708. private static readonly _LightsDirtyCallBack;
  20709. private static readonly _AttributeDirtyCallBack;
  20710. private static _FresnelAndMiscDirtyCallBack;
  20711. private static _TextureAndMiscDirtyCallBack;
  20712. private static readonly _DirtyCallbackArray;
  20713. private static readonly _RunDirtyCallBacks;
  20714. /**
  20715. * Marks a define in the material to indicate that it needs to be re-computed
  20716. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20717. */
  20718. markAsDirty(flag: number): void;
  20719. /**
  20720. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20721. * @param func defines a function which checks material defines against the submeshes
  20722. */
  20723. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20724. /**
  20725. * Indicates that we need to re-calculated for all submeshes
  20726. */
  20727. protected _markAllSubMeshesAsAllDirty(): void;
  20728. /**
  20729. * Indicates that image processing needs to be re-calculated for all submeshes
  20730. */
  20731. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20732. /**
  20733. * Indicates that textures need to be re-calculated for all submeshes
  20734. */
  20735. protected _markAllSubMeshesAsTexturesDirty(): void;
  20736. /**
  20737. * Indicates that fresnel needs to be re-calculated for all submeshes
  20738. */
  20739. protected _markAllSubMeshesAsFresnelDirty(): void;
  20740. /**
  20741. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20742. */
  20743. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20744. /**
  20745. * Indicates that lights need to be re-calculated for all submeshes
  20746. */
  20747. protected _markAllSubMeshesAsLightsDirty(): void;
  20748. /**
  20749. * Indicates that attributes need to be re-calculated for all submeshes
  20750. */
  20751. protected _markAllSubMeshesAsAttributesDirty(): void;
  20752. /**
  20753. * Indicates that misc needs to be re-calculated for all submeshes
  20754. */
  20755. protected _markAllSubMeshesAsMiscDirty(): void;
  20756. /**
  20757. * Indicates that textures and misc need to be re-calculated for all submeshes
  20758. */
  20759. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20760. /**
  20761. * Disposes the material
  20762. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20763. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20764. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20765. */
  20766. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20767. /** @hidden */
  20768. private releaseVertexArrayObject;
  20769. /**
  20770. * Serializes this material
  20771. * @returns the serialized material object
  20772. */
  20773. serialize(): any;
  20774. /**
  20775. * Creates a material from parsed material data
  20776. * @param parsedMaterial defines parsed material data
  20777. * @param scene defines the hosting scene
  20778. * @param rootUrl defines the root URL to use to load textures
  20779. * @returns a new material
  20780. */
  20781. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20782. }
  20783. }
  20784. declare module BABYLON {
  20785. /**
  20786. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20787. * separate meshes. This can be use to improve performances.
  20788. * @see http://doc.babylonjs.com/how_to/multi_materials
  20789. */
  20790. export class MultiMaterial extends Material {
  20791. private _subMaterials;
  20792. /**
  20793. * Gets or Sets the list of Materials used within the multi material.
  20794. * They need to be ordered according to the submeshes order in the associated mesh
  20795. */
  20796. subMaterials: Nullable<Material>[];
  20797. /**
  20798. * Function used to align with Node.getChildren()
  20799. * @returns the list of Materials used within the multi material
  20800. */
  20801. getChildren(): Nullable<Material>[];
  20802. /**
  20803. * Instantiates a new Multi Material
  20804. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20805. * separate meshes. This can be use to improve performances.
  20806. * @see http://doc.babylonjs.com/how_to/multi_materials
  20807. * @param name Define the name in the scene
  20808. * @param scene Define the scene the material belongs to
  20809. */
  20810. constructor(name: string, scene: Scene);
  20811. private _hookArray;
  20812. /**
  20813. * Get one of the submaterial by its index in the submaterials array
  20814. * @param index The index to look the sub material at
  20815. * @returns The Material if the index has been defined
  20816. */
  20817. getSubMaterial(index: number): Nullable<Material>;
  20818. /**
  20819. * Get the list of active textures for the whole sub materials list.
  20820. * @returns All the textures that will be used during the rendering
  20821. */
  20822. getActiveTextures(): BaseTexture[];
  20823. /**
  20824. * Gets the current class name of the material e.g. "MultiMaterial"
  20825. * Mainly use in serialization.
  20826. * @returns the class name
  20827. */
  20828. getClassName(): string;
  20829. /**
  20830. * Checks if the material is ready to render the requested sub mesh
  20831. * @param mesh Define the mesh the submesh belongs to
  20832. * @param subMesh Define the sub mesh to look readyness for
  20833. * @param useInstances Define whether or not the material is used with instances
  20834. * @returns true if ready, otherwise false
  20835. */
  20836. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20837. /**
  20838. * Clones the current material and its related sub materials
  20839. * @param name Define the name of the newly cloned material
  20840. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20841. * @returns the cloned material
  20842. */
  20843. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20844. /**
  20845. * Serializes the materials into a JSON representation.
  20846. * @returns the JSON representation
  20847. */
  20848. serialize(): any;
  20849. /**
  20850. * Dispose the material and release its associated resources
  20851. * @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)
  20852. * @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)
  20853. * @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)
  20854. */
  20855. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20856. /**
  20857. * Creates a MultiMaterial from parsed MultiMaterial data.
  20858. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20859. * @param scene defines the hosting scene
  20860. * @returns a new MultiMaterial
  20861. */
  20862. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20863. }
  20864. }
  20865. declare module BABYLON {
  20866. /**
  20867. * Base class for submeshes
  20868. */
  20869. export class BaseSubMesh {
  20870. /** @hidden */
  20871. _materialDefines: Nullable<MaterialDefines>;
  20872. /** @hidden */
  20873. _materialEffect: Nullable<Effect>;
  20874. /**
  20875. * Gets associated effect
  20876. */
  20877. readonly effect: Nullable<Effect>;
  20878. /**
  20879. * Sets associated effect (effect used to render this submesh)
  20880. * @param effect defines the effect to associate with
  20881. * @param defines defines the set of defines used to compile this effect
  20882. */
  20883. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20884. }
  20885. /**
  20886. * Defines a subdivision inside a mesh
  20887. */
  20888. export class SubMesh extends BaseSubMesh implements ICullable {
  20889. /** the material index to use */
  20890. materialIndex: number;
  20891. /** vertex index start */
  20892. verticesStart: number;
  20893. /** vertices count */
  20894. verticesCount: number;
  20895. /** index start */
  20896. indexStart: number;
  20897. /** indices count */
  20898. indexCount: number;
  20899. /** @hidden */
  20900. _linesIndexCount: number;
  20901. private _mesh;
  20902. private _renderingMesh;
  20903. private _boundingInfo;
  20904. private _linesIndexBuffer;
  20905. /** @hidden */
  20906. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20907. /** @hidden */
  20908. _trianglePlanes: Plane[];
  20909. /** @hidden */
  20910. _lastColliderTransformMatrix: Nullable<Matrix>;
  20911. /** @hidden */
  20912. _renderId: number;
  20913. /** @hidden */
  20914. _alphaIndex: number;
  20915. /** @hidden */
  20916. _distanceToCamera: number;
  20917. /** @hidden */
  20918. _id: number;
  20919. private _currentMaterial;
  20920. /**
  20921. * Add a new submesh to a mesh
  20922. * @param materialIndex defines the material index to use
  20923. * @param verticesStart defines vertex index start
  20924. * @param verticesCount defines vertices count
  20925. * @param indexStart defines index start
  20926. * @param indexCount defines indices count
  20927. * @param mesh defines the parent mesh
  20928. * @param renderingMesh defines an optional rendering mesh
  20929. * @param createBoundingBox defines if bounding box should be created for this submesh
  20930. * @returns the new submesh
  20931. */
  20932. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20933. /**
  20934. * Creates a new submesh
  20935. * @param materialIndex defines the material index to use
  20936. * @param verticesStart defines vertex index start
  20937. * @param verticesCount defines vertices count
  20938. * @param indexStart defines index start
  20939. * @param indexCount defines indices count
  20940. * @param mesh defines the parent mesh
  20941. * @param renderingMesh defines an optional rendering mesh
  20942. * @param createBoundingBox defines if bounding box should be created for this submesh
  20943. */
  20944. constructor(
  20945. /** the material index to use */
  20946. materialIndex: number,
  20947. /** vertex index start */
  20948. verticesStart: number,
  20949. /** vertices count */
  20950. verticesCount: number,
  20951. /** index start */
  20952. indexStart: number,
  20953. /** indices count */
  20954. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20955. /**
  20956. * Returns true if this submesh covers the entire parent mesh
  20957. * @ignorenaming
  20958. */
  20959. readonly IsGlobal: boolean;
  20960. /**
  20961. * Returns the submesh BoudingInfo object
  20962. * @returns current bounding info (or mesh's one if the submesh is global)
  20963. */
  20964. getBoundingInfo(): BoundingInfo;
  20965. /**
  20966. * Sets the submesh BoundingInfo
  20967. * @param boundingInfo defines the new bounding info to use
  20968. * @returns the SubMesh
  20969. */
  20970. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20971. /**
  20972. * Returns the mesh of the current submesh
  20973. * @return the parent mesh
  20974. */
  20975. getMesh(): AbstractMesh;
  20976. /**
  20977. * Returns the rendering mesh of the submesh
  20978. * @returns the rendering mesh (could be different from parent mesh)
  20979. */
  20980. getRenderingMesh(): Mesh;
  20981. /**
  20982. * Returns the submesh material
  20983. * @returns null or the current material
  20984. */
  20985. getMaterial(): Nullable<Material>;
  20986. /**
  20987. * Sets a new updated BoundingInfo object to the submesh
  20988. * @param data defines an optional position array to use to determine the bounding info
  20989. * @returns the SubMesh
  20990. */
  20991. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20992. /** @hidden */
  20993. _checkCollision(collider: Collider): boolean;
  20994. /**
  20995. * Updates the submesh BoundingInfo
  20996. * @param world defines the world matrix to use to update the bounding info
  20997. * @returns the submesh
  20998. */
  20999. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21000. /**
  21001. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21002. * @param frustumPlanes defines the frustum planes
  21003. * @returns true if the submesh is intersecting with the frustum
  21004. */
  21005. isInFrustum(frustumPlanes: Plane[]): boolean;
  21006. /**
  21007. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21008. * @param frustumPlanes defines the frustum planes
  21009. * @returns true if the submesh is inside the frustum
  21010. */
  21011. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21012. /**
  21013. * Renders the submesh
  21014. * @param enableAlphaMode defines if alpha needs to be used
  21015. * @returns the submesh
  21016. */
  21017. render(enableAlphaMode: boolean): SubMesh;
  21018. /**
  21019. * @hidden
  21020. */
  21021. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21022. /**
  21023. * Checks if the submesh intersects with a ray
  21024. * @param ray defines the ray to test
  21025. * @returns true is the passed ray intersects the submesh bounding box
  21026. */
  21027. canIntersects(ray: Ray): boolean;
  21028. /**
  21029. * Intersects current submesh with a ray
  21030. * @param ray defines the ray to test
  21031. * @param positions defines mesh's positions array
  21032. * @param indices defines mesh's indices array
  21033. * @param fastCheck defines if only bounding info should be used
  21034. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21035. * @returns intersection info or null if no intersection
  21036. */
  21037. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21038. /** @hidden */
  21039. private _intersectLines;
  21040. /** @hidden */
  21041. private _intersectUnIndexedLines;
  21042. /** @hidden */
  21043. private _intersectTriangles;
  21044. /** @hidden */
  21045. private _intersectUnIndexedTriangles;
  21046. /** @hidden */
  21047. _rebuild(): void;
  21048. /**
  21049. * Creates a new submesh from the passed mesh
  21050. * @param newMesh defines the new hosting mesh
  21051. * @param newRenderingMesh defines an optional rendering mesh
  21052. * @returns the new submesh
  21053. */
  21054. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21055. /**
  21056. * Release associated resources
  21057. */
  21058. dispose(): void;
  21059. /**
  21060. * Gets the class name
  21061. * @returns the string "SubMesh".
  21062. */
  21063. getClassName(): string;
  21064. /**
  21065. * Creates a new submesh from indices data
  21066. * @param materialIndex the index of the main mesh material
  21067. * @param startIndex the index where to start the copy in the mesh indices array
  21068. * @param indexCount the number of indices to copy then from the startIndex
  21069. * @param mesh the main mesh to create the submesh from
  21070. * @param renderingMesh the optional rendering mesh
  21071. * @returns a new submesh
  21072. */
  21073. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21074. }
  21075. }
  21076. declare module BABYLON {
  21077. /**
  21078. * Class used to represent data loading progression
  21079. */
  21080. export class SceneLoaderFlags {
  21081. private static _ForceFullSceneLoadingForIncremental;
  21082. private static _ShowLoadingScreen;
  21083. private static _CleanBoneMatrixWeights;
  21084. private static _loggingLevel;
  21085. /**
  21086. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21087. */
  21088. static ForceFullSceneLoadingForIncremental: boolean;
  21089. /**
  21090. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21091. */
  21092. static ShowLoadingScreen: boolean;
  21093. /**
  21094. * Defines the current logging level (while loading the scene)
  21095. * @ignorenaming
  21096. */
  21097. static loggingLevel: number;
  21098. /**
  21099. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21100. */
  21101. static CleanBoneMatrixWeights: boolean;
  21102. }
  21103. }
  21104. declare module BABYLON {
  21105. /**
  21106. * Class used to store geometry data (vertex buffers + index buffer)
  21107. */
  21108. export class Geometry implements IGetSetVerticesData {
  21109. /**
  21110. * Gets or sets the ID of the geometry
  21111. */
  21112. id: string;
  21113. /**
  21114. * Gets or sets the unique ID of the geometry
  21115. */
  21116. uniqueId: number;
  21117. /**
  21118. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21119. */
  21120. delayLoadState: number;
  21121. /**
  21122. * Gets the file containing the data to load when running in delay load state
  21123. */
  21124. delayLoadingFile: Nullable<string>;
  21125. /**
  21126. * Callback called when the geometry is updated
  21127. */
  21128. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21129. private _scene;
  21130. private _engine;
  21131. private _meshes;
  21132. private _totalVertices;
  21133. /** @hidden */
  21134. _indices: IndicesArray;
  21135. /** @hidden */
  21136. _vertexBuffers: {
  21137. [key: string]: VertexBuffer;
  21138. };
  21139. private _isDisposed;
  21140. private _extend;
  21141. private _boundingBias;
  21142. /** @hidden */
  21143. _delayInfo: Array<string>;
  21144. private _indexBuffer;
  21145. private _indexBufferIsUpdatable;
  21146. /** @hidden */
  21147. _boundingInfo: Nullable<BoundingInfo>;
  21148. /** @hidden */
  21149. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21150. /** @hidden */
  21151. _softwareSkinningFrameId: number;
  21152. private _vertexArrayObjects;
  21153. private _updatable;
  21154. /** @hidden */
  21155. _positions: Nullable<Vector3[]>;
  21156. /**
  21157. * 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
  21158. */
  21159. /**
  21160. * 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
  21161. */
  21162. boundingBias: Vector2;
  21163. /**
  21164. * Static function used to attach a new empty geometry to a mesh
  21165. * @param mesh defines the mesh to attach the geometry to
  21166. * @returns the new Geometry
  21167. */
  21168. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21169. /**
  21170. * Creates a new geometry
  21171. * @param id defines the unique ID
  21172. * @param scene defines the hosting scene
  21173. * @param vertexData defines the VertexData used to get geometry data
  21174. * @param updatable defines if geometry must be updatable (false by default)
  21175. * @param mesh defines the mesh that will be associated with the geometry
  21176. */
  21177. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21178. /**
  21179. * Gets the current extend of the geometry
  21180. */
  21181. readonly extend: {
  21182. minimum: Vector3;
  21183. maximum: Vector3;
  21184. };
  21185. /**
  21186. * Gets the hosting scene
  21187. * @returns the hosting Scene
  21188. */
  21189. getScene(): Scene;
  21190. /**
  21191. * Gets the hosting engine
  21192. * @returns the hosting Engine
  21193. */
  21194. getEngine(): Engine;
  21195. /**
  21196. * Defines if the geometry is ready to use
  21197. * @returns true if the geometry is ready to be used
  21198. */
  21199. isReady(): boolean;
  21200. /**
  21201. * Gets a value indicating that the geometry should not be serialized
  21202. */
  21203. readonly doNotSerialize: boolean;
  21204. /** @hidden */
  21205. _rebuild(): void;
  21206. /**
  21207. * Affects all geometry data in one call
  21208. * @param vertexData defines the geometry data
  21209. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21210. */
  21211. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21212. /**
  21213. * Set specific vertex data
  21214. * @param kind defines the data kind (Position, normal, etc...)
  21215. * @param data defines the vertex data to use
  21216. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21217. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21218. */
  21219. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21220. /**
  21221. * Removes a specific vertex data
  21222. * @param kind defines the data kind (Position, normal, etc...)
  21223. */
  21224. removeVerticesData(kind: string): void;
  21225. /**
  21226. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21227. * @param buffer defines the vertex buffer to use
  21228. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21229. */
  21230. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21231. /**
  21232. * Update a specific vertex buffer
  21233. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21234. * It will do nothing if the buffer is not updatable
  21235. * @param kind defines the data kind (Position, normal, etc...)
  21236. * @param data defines the data to use
  21237. * @param offset defines the offset in the target buffer where to store the data
  21238. * @param useBytes set to true if the offset is in bytes
  21239. */
  21240. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21241. /**
  21242. * Update a specific vertex buffer
  21243. * This function will create a new buffer if the current one is not updatable
  21244. * @param kind defines the data kind (Position, normal, etc...)
  21245. * @param data defines the data to use
  21246. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21247. */
  21248. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21249. private _updateBoundingInfo;
  21250. /** @hidden */
  21251. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21252. /**
  21253. * Gets total number of vertices
  21254. * @returns the total number of vertices
  21255. */
  21256. getTotalVertices(): number;
  21257. /**
  21258. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21259. * @param kind defines the data kind (Position, normal, etc...)
  21260. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21261. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21262. * @returns a float array containing vertex data
  21263. */
  21264. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21265. /**
  21266. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21267. * @param kind defines the data kind (Position, normal, etc...)
  21268. * @returns true if the vertex buffer with the specified kind is updatable
  21269. */
  21270. isVertexBufferUpdatable(kind: string): boolean;
  21271. /**
  21272. * Gets a specific vertex buffer
  21273. * @param kind defines the data kind (Position, normal, etc...)
  21274. * @returns a VertexBuffer
  21275. */
  21276. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21277. /**
  21278. * Returns all vertex buffers
  21279. * @return an object holding all vertex buffers indexed by kind
  21280. */
  21281. getVertexBuffers(): Nullable<{
  21282. [key: string]: VertexBuffer;
  21283. }>;
  21284. /**
  21285. * Gets a boolean indicating if specific vertex buffer is present
  21286. * @param kind defines the data kind (Position, normal, etc...)
  21287. * @returns true if data is present
  21288. */
  21289. isVerticesDataPresent(kind: string): boolean;
  21290. /**
  21291. * Gets a list of all attached data kinds (Position, normal, etc...)
  21292. * @returns a list of string containing all kinds
  21293. */
  21294. getVerticesDataKinds(): string[];
  21295. /**
  21296. * Update index buffer
  21297. * @param indices defines the indices to store in the index buffer
  21298. * @param offset defines the offset in the target buffer where to store the data
  21299. * @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)
  21300. */
  21301. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21302. /**
  21303. * Creates a new index buffer
  21304. * @param indices defines the indices to store in the index buffer
  21305. * @param totalVertices defines the total number of vertices (could be null)
  21306. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21307. */
  21308. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21309. /**
  21310. * Return the total number of indices
  21311. * @returns the total number of indices
  21312. */
  21313. getTotalIndices(): number;
  21314. /**
  21315. * Gets the index buffer array
  21316. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21317. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21318. * @returns the index buffer array
  21319. */
  21320. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21321. /**
  21322. * Gets the index buffer
  21323. * @return the index buffer
  21324. */
  21325. getIndexBuffer(): Nullable<DataBuffer>;
  21326. /** @hidden */
  21327. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21328. /**
  21329. * Release the associated resources for a specific mesh
  21330. * @param mesh defines the source mesh
  21331. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21332. */
  21333. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21334. /**
  21335. * Apply current geometry to a given mesh
  21336. * @param mesh defines the mesh to apply geometry to
  21337. */
  21338. applyToMesh(mesh: Mesh): void;
  21339. private _updateExtend;
  21340. private _applyToMesh;
  21341. private notifyUpdate;
  21342. /**
  21343. * Load the geometry if it was flagged as delay loaded
  21344. * @param scene defines the hosting scene
  21345. * @param onLoaded defines a callback called when the geometry is loaded
  21346. */
  21347. load(scene: Scene, onLoaded?: () => void): void;
  21348. private _queueLoad;
  21349. /**
  21350. * Invert the geometry to move from a right handed system to a left handed one.
  21351. */
  21352. toLeftHanded(): void;
  21353. /** @hidden */
  21354. _resetPointsArrayCache(): void;
  21355. /** @hidden */
  21356. _generatePointsArray(): boolean;
  21357. /**
  21358. * Gets a value indicating if the geometry is disposed
  21359. * @returns true if the geometry was disposed
  21360. */
  21361. isDisposed(): boolean;
  21362. private _disposeVertexArrayObjects;
  21363. /**
  21364. * Free all associated resources
  21365. */
  21366. dispose(): void;
  21367. /**
  21368. * Clone the current geometry into a new geometry
  21369. * @param id defines the unique ID of the new geometry
  21370. * @returns a new geometry object
  21371. */
  21372. copy(id: string): Geometry;
  21373. /**
  21374. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21375. * @return a JSON representation of the current geometry data (without the vertices data)
  21376. */
  21377. serialize(): any;
  21378. private toNumberArray;
  21379. /**
  21380. * Serialize all vertices data into a JSON oject
  21381. * @returns a JSON representation of the current geometry data
  21382. */
  21383. serializeVerticeData(): any;
  21384. /**
  21385. * Extracts a clone of a mesh geometry
  21386. * @param mesh defines the source mesh
  21387. * @param id defines the unique ID of the new geometry object
  21388. * @returns the new geometry object
  21389. */
  21390. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21391. /**
  21392. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21393. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21394. * Be aware Math.random() could cause collisions, but:
  21395. * "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"
  21396. * @returns a string containing a new GUID
  21397. */
  21398. static RandomId(): string;
  21399. /** @hidden */
  21400. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21401. private static _CleanMatricesWeights;
  21402. /**
  21403. * Create a new geometry from persisted data (Using .babylon file format)
  21404. * @param parsedVertexData defines the persisted data
  21405. * @param scene defines the hosting scene
  21406. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21407. * @returns the new geometry object
  21408. */
  21409. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21410. }
  21411. }
  21412. declare module BABYLON {
  21413. /**
  21414. * Define an interface for all classes that will get and set the data on vertices
  21415. */
  21416. export interface IGetSetVerticesData {
  21417. /**
  21418. * Gets a boolean indicating if specific vertex data is present
  21419. * @param kind defines the vertex data kind to use
  21420. * @returns true is data kind is present
  21421. */
  21422. isVerticesDataPresent(kind: string): boolean;
  21423. /**
  21424. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21425. * @param kind defines the data kind (Position, normal, etc...)
  21426. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21427. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21428. * @returns a float array containing vertex data
  21429. */
  21430. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21431. /**
  21432. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21433. * @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.
  21434. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21435. * @returns the indices array or an empty array if the mesh has no geometry
  21436. */
  21437. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21438. /**
  21439. * Set specific vertex data
  21440. * @param kind defines the data kind (Position, normal, etc...)
  21441. * @param data defines the vertex data to use
  21442. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21443. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21444. */
  21445. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21446. /**
  21447. * Update a specific associated vertex buffer
  21448. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21449. * - VertexBuffer.PositionKind
  21450. * - VertexBuffer.UVKind
  21451. * - VertexBuffer.UV2Kind
  21452. * - VertexBuffer.UV3Kind
  21453. * - VertexBuffer.UV4Kind
  21454. * - VertexBuffer.UV5Kind
  21455. * - VertexBuffer.UV6Kind
  21456. * - VertexBuffer.ColorKind
  21457. * - VertexBuffer.MatricesIndicesKind
  21458. * - VertexBuffer.MatricesIndicesExtraKind
  21459. * - VertexBuffer.MatricesWeightsKind
  21460. * - VertexBuffer.MatricesWeightsExtraKind
  21461. * @param data defines the data source
  21462. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21463. * @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)
  21464. */
  21465. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21466. /**
  21467. * Creates a new index buffer
  21468. * @param indices defines the indices to store in the index buffer
  21469. * @param totalVertices defines the total number of vertices (could be null)
  21470. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21471. */
  21472. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21473. }
  21474. /**
  21475. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21476. */
  21477. export class VertexData {
  21478. /**
  21479. * Mesh side orientation : usually the external or front surface
  21480. */
  21481. static readonly FRONTSIDE: number;
  21482. /**
  21483. * Mesh side orientation : usually the internal or back surface
  21484. */
  21485. static readonly BACKSIDE: number;
  21486. /**
  21487. * Mesh side orientation : both internal and external or front and back surfaces
  21488. */
  21489. static readonly DOUBLESIDE: number;
  21490. /**
  21491. * Mesh side orientation : by default, `FRONTSIDE`
  21492. */
  21493. static readonly DEFAULTSIDE: number;
  21494. /**
  21495. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21496. */
  21497. positions: Nullable<FloatArray>;
  21498. /**
  21499. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21500. */
  21501. normals: Nullable<FloatArray>;
  21502. /**
  21503. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21504. */
  21505. tangents: Nullable<FloatArray>;
  21506. /**
  21507. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21508. */
  21509. uvs: Nullable<FloatArray>;
  21510. /**
  21511. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21512. */
  21513. uvs2: Nullable<FloatArray>;
  21514. /**
  21515. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21516. */
  21517. uvs3: Nullable<FloatArray>;
  21518. /**
  21519. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21520. */
  21521. uvs4: Nullable<FloatArray>;
  21522. /**
  21523. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21524. */
  21525. uvs5: Nullable<FloatArray>;
  21526. /**
  21527. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21528. */
  21529. uvs6: Nullable<FloatArray>;
  21530. /**
  21531. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21532. */
  21533. colors: Nullable<FloatArray>;
  21534. /**
  21535. * 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).
  21536. */
  21537. matricesIndices: Nullable<FloatArray>;
  21538. /**
  21539. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21540. */
  21541. matricesWeights: Nullable<FloatArray>;
  21542. /**
  21543. * An array extending the number of possible indices
  21544. */
  21545. matricesIndicesExtra: Nullable<FloatArray>;
  21546. /**
  21547. * An array extending the number of possible weights when the number of indices is extended
  21548. */
  21549. matricesWeightsExtra: Nullable<FloatArray>;
  21550. /**
  21551. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21552. */
  21553. indices: Nullable<IndicesArray>;
  21554. /**
  21555. * Uses the passed data array to set the set the values for the specified kind of data
  21556. * @param data a linear array of floating numbers
  21557. * @param kind the type of data that is being set, eg positions, colors etc
  21558. */
  21559. set(data: FloatArray, kind: string): void;
  21560. /**
  21561. * Associates the vertexData to the passed Mesh.
  21562. * Sets it as updatable or not (default `false`)
  21563. * @param mesh the mesh the vertexData is applied to
  21564. * @param updatable when used and having the value true allows new data to update the vertexData
  21565. * @returns the VertexData
  21566. */
  21567. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21568. /**
  21569. * Associates the vertexData to the passed Geometry.
  21570. * Sets it as updatable or not (default `false`)
  21571. * @param geometry the geometry the vertexData is applied to
  21572. * @param updatable when used and having the value true allows new data to update the vertexData
  21573. * @returns VertexData
  21574. */
  21575. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21576. /**
  21577. * Updates the associated mesh
  21578. * @param mesh the mesh to be updated
  21579. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21580. * @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
  21581. * @returns VertexData
  21582. */
  21583. updateMesh(mesh: Mesh): VertexData;
  21584. /**
  21585. * Updates the associated geometry
  21586. * @param geometry the geometry to be updated
  21587. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21588. * @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
  21589. * @returns VertexData.
  21590. */
  21591. updateGeometry(geometry: Geometry): VertexData;
  21592. private _applyTo;
  21593. private _update;
  21594. /**
  21595. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21596. * @param matrix the transforming matrix
  21597. * @returns the VertexData
  21598. */
  21599. transform(matrix: Matrix): VertexData;
  21600. /**
  21601. * Merges the passed VertexData into the current one
  21602. * @param other the VertexData to be merged into the current one
  21603. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21604. * @returns the modified VertexData
  21605. */
  21606. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21607. private _mergeElement;
  21608. private _validate;
  21609. /**
  21610. * Serializes the VertexData
  21611. * @returns a serialized object
  21612. */
  21613. serialize(): any;
  21614. /**
  21615. * Extracts the vertexData from a mesh
  21616. * @param mesh the mesh from which to extract the VertexData
  21617. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21618. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21619. * @returns the object VertexData associated to the passed mesh
  21620. */
  21621. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21622. /**
  21623. * Extracts the vertexData from the geometry
  21624. * @param geometry the geometry from which to extract the VertexData
  21625. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21626. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21627. * @returns the object VertexData associated to the passed mesh
  21628. */
  21629. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21630. private static _ExtractFrom;
  21631. /**
  21632. * Creates the VertexData for a Ribbon
  21633. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21634. * * pathArray array of paths, each of which an array of successive Vector3
  21635. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21636. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21637. * * 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
  21638. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21639. * * 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)
  21640. * * 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)
  21641. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21642. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21643. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21644. * @returns the VertexData of the ribbon
  21645. */
  21646. static CreateRibbon(options: {
  21647. pathArray: Vector3[][];
  21648. closeArray?: boolean;
  21649. closePath?: boolean;
  21650. offset?: number;
  21651. sideOrientation?: number;
  21652. frontUVs?: Vector4;
  21653. backUVs?: Vector4;
  21654. invertUV?: boolean;
  21655. uvs?: Vector2[];
  21656. colors?: Color4[];
  21657. }): VertexData;
  21658. /**
  21659. * Creates the VertexData for a box
  21660. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21661. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21662. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21663. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21664. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21665. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21666. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21667. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21668. * * 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)
  21669. * * 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)
  21670. * @returns the VertexData of the box
  21671. */
  21672. static CreateBox(options: {
  21673. size?: number;
  21674. width?: number;
  21675. height?: number;
  21676. depth?: number;
  21677. faceUV?: Vector4[];
  21678. faceColors?: Color4[];
  21679. sideOrientation?: number;
  21680. frontUVs?: Vector4;
  21681. backUVs?: Vector4;
  21682. }): VertexData;
  21683. /**
  21684. * Creates the VertexData for a tiled box
  21685. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21686. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21687. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21688. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21689. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21690. * @returns the VertexData of the box
  21691. */
  21692. static CreateTiledBox(options: {
  21693. pattern?: number;
  21694. width?: number;
  21695. height?: number;
  21696. depth?: number;
  21697. tileSize?: number;
  21698. tileWidth?: number;
  21699. tileHeight?: number;
  21700. alignHorizontal?: number;
  21701. alignVertical?: number;
  21702. faceUV?: Vector4[];
  21703. faceColors?: Color4[];
  21704. sideOrientation?: number;
  21705. }): VertexData;
  21706. /**
  21707. * Creates the VertexData for a tiled plane
  21708. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21709. * * pattern a limited pattern arrangement depending on the number
  21710. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21711. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21712. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21713. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21714. * * 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)
  21715. * * 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)
  21716. * @returns the VertexData of the tiled plane
  21717. */
  21718. static CreateTiledPlane(options: {
  21719. pattern?: number;
  21720. tileSize?: number;
  21721. tileWidth?: number;
  21722. tileHeight?: number;
  21723. size?: number;
  21724. width?: number;
  21725. height?: number;
  21726. alignHorizontal?: number;
  21727. alignVertical?: number;
  21728. sideOrientation?: number;
  21729. frontUVs?: Vector4;
  21730. backUVs?: Vector4;
  21731. }): VertexData;
  21732. /**
  21733. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21734. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21735. * * segments sets the number of horizontal strips optional, default 32
  21736. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21737. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21738. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21739. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21740. * * 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
  21741. * * 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
  21742. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21743. * * 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)
  21744. * * 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)
  21745. * @returns the VertexData of the ellipsoid
  21746. */
  21747. static CreateSphere(options: {
  21748. segments?: number;
  21749. diameter?: number;
  21750. diameterX?: number;
  21751. diameterY?: number;
  21752. diameterZ?: number;
  21753. arc?: number;
  21754. slice?: number;
  21755. sideOrientation?: number;
  21756. frontUVs?: Vector4;
  21757. backUVs?: Vector4;
  21758. }): VertexData;
  21759. /**
  21760. * Creates the VertexData for a cylinder, cone or prism
  21761. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21762. * * height sets the height (y direction) of the cylinder, optional, default 2
  21763. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21764. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21765. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21766. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21767. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21768. * * 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
  21769. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21770. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21771. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21772. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21773. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21774. * * 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)
  21775. * * 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)
  21776. * @returns the VertexData of the cylinder, cone or prism
  21777. */
  21778. static CreateCylinder(options: {
  21779. height?: number;
  21780. diameterTop?: number;
  21781. diameterBottom?: number;
  21782. diameter?: number;
  21783. tessellation?: number;
  21784. subdivisions?: number;
  21785. arc?: number;
  21786. faceColors?: Color4[];
  21787. faceUV?: Vector4[];
  21788. hasRings?: boolean;
  21789. enclose?: boolean;
  21790. sideOrientation?: number;
  21791. frontUVs?: Vector4;
  21792. backUVs?: Vector4;
  21793. }): VertexData;
  21794. /**
  21795. * Creates the VertexData for a torus
  21796. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21797. * * diameter the diameter of the torus, optional default 1
  21798. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21799. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21800. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21801. * * 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)
  21802. * * 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)
  21803. * @returns the VertexData of the torus
  21804. */
  21805. static CreateTorus(options: {
  21806. diameter?: number;
  21807. thickness?: number;
  21808. tessellation?: number;
  21809. sideOrientation?: number;
  21810. frontUVs?: Vector4;
  21811. backUVs?: Vector4;
  21812. }): VertexData;
  21813. /**
  21814. * Creates the VertexData of the LineSystem
  21815. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21816. * - lines an array of lines, each line being an array of successive Vector3
  21817. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21818. * @returns the VertexData of the LineSystem
  21819. */
  21820. static CreateLineSystem(options: {
  21821. lines: Vector3[][];
  21822. colors?: Nullable<Color4[][]>;
  21823. }): VertexData;
  21824. /**
  21825. * Create the VertexData for a DashedLines
  21826. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21827. * - points an array successive Vector3
  21828. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21829. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21830. * - dashNb the intended total number of dashes, optional, default 200
  21831. * @returns the VertexData for the DashedLines
  21832. */
  21833. static CreateDashedLines(options: {
  21834. points: Vector3[];
  21835. dashSize?: number;
  21836. gapSize?: number;
  21837. dashNb?: number;
  21838. }): VertexData;
  21839. /**
  21840. * Creates the VertexData for a Ground
  21841. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21842. * - width the width (x direction) of the ground, optional, default 1
  21843. * - height the height (z direction) of the ground, optional, default 1
  21844. * - subdivisions the number of subdivisions per side, optional, default 1
  21845. * @returns the VertexData of the Ground
  21846. */
  21847. static CreateGround(options: {
  21848. width?: number;
  21849. height?: number;
  21850. subdivisions?: number;
  21851. subdivisionsX?: number;
  21852. subdivisionsY?: number;
  21853. }): VertexData;
  21854. /**
  21855. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21856. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21857. * * xmin the ground minimum X coordinate, optional, default -1
  21858. * * zmin the ground minimum Z coordinate, optional, default -1
  21859. * * xmax the ground maximum X coordinate, optional, default 1
  21860. * * zmax the ground maximum Z coordinate, optional, default 1
  21861. * * 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}
  21862. * * 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}
  21863. * @returns the VertexData of the TiledGround
  21864. */
  21865. static CreateTiledGround(options: {
  21866. xmin: number;
  21867. zmin: number;
  21868. xmax: number;
  21869. zmax: number;
  21870. subdivisions?: {
  21871. w: number;
  21872. h: number;
  21873. };
  21874. precision?: {
  21875. w: number;
  21876. h: number;
  21877. };
  21878. }): VertexData;
  21879. /**
  21880. * Creates the VertexData of the Ground designed from a heightmap
  21881. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21882. * * width the width (x direction) of the ground
  21883. * * height the height (z direction) of the ground
  21884. * * subdivisions the number of subdivisions per side
  21885. * * minHeight the minimum altitude on the ground, optional, default 0
  21886. * * maxHeight the maximum altitude on the ground, optional default 1
  21887. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21888. * * buffer the array holding the image color data
  21889. * * bufferWidth the width of image
  21890. * * bufferHeight the height of image
  21891. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21892. * @returns the VertexData of the Ground designed from a heightmap
  21893. */
  21894. static CreateGroundFromHeightMap(options: {
  21895. width: number;
  21896. height: number;
  21897. subdivisions: number;
  21898. minHeight: number;
  21899. maxHeight: number;
  21900. colorFilter: Color3;
  21901. buffer: Uint8Array;
  21902. bufferWidth: number;
  21903. bufferHeight: number;
  21904. alphaFilter: number;
  21905. }): VertexData;
  21906. /**
  21907. * Creates the VertexData for a Plane
  21908. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21909. * * size sets the width and height of the plane to the value of size, optional default 1
  21910. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21911. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21912. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21913. * * 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)
  21914. * * 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)
  21915. * @returns the VertexData of the box
  21916. */
  21917. static CreatePlane(options: {
  21918. size?: number;
  21919. width?: number;
  21920. height?: number;
  21921. sideOrientation?: number;
  21922. frontUVs?: Vector4;
  21923. backUVs?: Vector4;
  21924. }): VertexData;
  21925. /**
  21926. * Creates the VertexData of the Disc or regular Polygon
  21927. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21928. * * radius the radius of the disc, optional default 0.5
  21929. * * tessellation the number of polygon sides, optional, default 64
  21930. * * 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
  21931. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21932. * * 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)
  21933. * * 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)
  21934. * @returns the VertexData of the box
  21935. */
  21936. static CreateDisc(options: {
  21937. radius?: number;
  21938. tessellation?: number;
  21939. arc?: number;
  21940. sideOrientation?: number;
  21941. frontUVs?: Vector4;
  21942. backUVs?: Vector4;
  21943. }): VertexData;
  21944. /**
  21945. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21946. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21947. * @param polygon a mesh built from polygonTriangulation.build()
  21948. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21949. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21950. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21951. * @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)
  21952. * @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)
  21953. * @returns the VertexData of the Polygon
  21954. */
  21955. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21956. /**
  21957. * Creates the VertexData of the IcoSphere
  21958. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21959. * * radius the radius of the IcoSphere, optional default 1
  21960. * * radiusX allows stretching in the x direction, optional, default radius
  21961. * * radiusY allows stretching in the y direction, optional, default radius
  21962. * * radiusZ allows stretching in the z direction, optional, default radius
  21963. * * flat when true creates a flat shaded mesh, optional, default true
  21964. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21965. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21966. * * 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)
  21967. * * 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)
  21968. * @returns the VertexData of the IcoSphere
  21969. */
  21970. static CreateIcoSphere(options: {
  21971. radius?: number;
  21972. radiusX?: number;
  21973. radiusY?: number;
  21974. radiusZ?: number;
  21975. flat?: boolean;
  21976. subdivisions?: number;
  21977. sideOrientation?: number;
  21978. frontUVs?: Vector4;
  21979. backUVs?: Vector4;
  21980. }): VertexData;
  21981. /**
  21982. * Creates the VertexData for a Polyhedron
  21983. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21984. * * type provided types are:
  21985. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21986. * * 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)
  21987. * * size the size of the IcoSphere, optional default 1
  21988. * * sizeX allows stretching in the x direction, optional, default size
  21989. * * sizeY allows stretching in the y direction, optional, default size
  21990. * * sizeZ allows stretching in the z direction, optional, default size
  21991. * * 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
  21992. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21993. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21994. * * flat when true creates a flat shaded mesh, optional, default true
  21995. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21996. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21997. * * 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)
  21998. * * 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)
  21999. * @returns the VertexData of the Polyhedron
  22000. */
  22001. static CreatePolyhedron(options: {
  22002. type?: number;
  22003. size?: number;
  22004. sizeX?: number;
  22005. sizeY?: number;
  22006. sizeZ?: number;
  22007. custom?: any;
  22008. faceUV?: Vector4[];
  22009. faceColors?: Color4[];
  22010. flat?: boolean;
  22011. sideOrientation?: number;
  22012. frontUVs?: Vector4;
  22013. backUVs?: Vector4;
  22014. }): VertexData;
  22015. /**
  22016. * Creates the VertexData for a TorusKnot
  22017. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22018. * * radius the radius of the torus knot, optional, default 2
  22019. * * tube the thickness of the tube, optional, default 0.5
  22020. * * radialSegments the number of sides on each tube segments, optional, default 32
  22021. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22022. * * p the number of windings around the z axis, optional, default 2
  22023. * * q the number of windings around the x axis, optional, default 3
  22024. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22025. * * 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)
  22026. * * 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)
  22027. * @returns the VertexData of the Torus Knot
  22028. */
  22029. static CreateTorusKnot(options: {
  22030. radius?: number;
  22031. tube?: number;
  22032. radialSegments?: number;
  22033. tubularSegments?: number;
  22034. p?: number;
  22035. q?: number;
  22036. sideOrientation?: number;
  22037. frontUVs?: Vector4;
  22038. backUVs?: Vector4;
  22039. }): VertexData;
  22040. /**
  22041. * Compute normals for given positions and indices
  22042. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22043. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22044. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22045. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22046. * * facetNormals : optional array of facet normals (vector3)
  22047. * * facetPositions : optional array of facet positions (vector3)
  22048. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22049. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22050. * * bInfo : optional bounding info, required for facetPartitioning computation
  22051. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22052. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22053. * * useRightHandedSystem: optional boolean to for right handed system computation
  22054. * * depthSort : optional boolean to enable the facet depth sort computation
  22055. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22056. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22057. */
  22058. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22059. facetNormals?: any;
  22060. facetPositions?: any;
  22061. facetPartitioning?: any;
  22062. ratio?: number;
  22063. bInfo?: any;
  22064. bbSize?: Vector3;
  22065. subDiv?: any;
  22066. useRightHandedSystem?: boolean;
  22067. depthSort?: boolean;
  22068. distanceTo?: Vector3;
  22069. depthSortedFacets?: any;
  22070. }): void;
  22071. /** @hidden */
  22072. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22073. /**
  22074. * Applies VertexData created from the imported parameters to the geometry
  22075. * @param parsedVertexData the parsed data from an imported file
  22076. * @param geometry the geometry to apply the VertexData to
  22077. */
  22078. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22079. }
  22080. }
  22081. declare module BABYLON {
  22082. /**
  22083. * Defines a target to use with MorphTargetManager
  22084. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22085. */
  22086. export class MorphTarget implements IAnimatable {
  22087. /** defines the name of the target */
  22088. name: string;
  22089. /**
  22090. * Gets or sets the list of animations
  22091. */
  22092. animations: Animation[];
  22093. private _scene;
  22094. private _positions;
  22095. private _normals;
  22096. private _tangents;
  22097. private _uvs;
  22098. private _influence;
  22099. /**
  22100. * Observable raised when the influence changes
  22101. */
  22102. onInfluenceChanged: Observable<boolean>;
  22103. /** @hidden */
  22104. _onDataLayoutChanged: Observable<void>;
  22105. /**
  22106. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22107. */
  22108. influence: number;
  22109. /**
  22110. * Gets or sets the id of the morph Target
  22111. */
  22112. id: string;
  22113. private _animationPropertiesOverride;
  22114. /**
  22115. * Gets or sets the animation properties override
  22116. */
  22117. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22118. /**
  22119. * Creates a new MorphTarget
  22120. * @param name defines the name of the target
  22121. * @param influence defines the influence to use
  22122. * @param scene defines the scene the morphtarget belongs to
  22123. */
  22124. constructor(
  22125. /** defines the name of the target */
  22126. name: string, influence?: number, scene?: Nullable<Scene>);
  22127. /**
  22128. * Gets a boolean defining if the target contains position data
  22129. */
  22130. readonly hasPositions: boolean;
  22131. /**
  22132. * Gets a boolean defining if the target contains normal data
  22133. */
  22134. readonly hasNormals: boolean;
  22135. /**
  22136. * Gets a boolean defining if the target contains tangent data
  22137. */
  22138. readonly hasTangents: boolean;
  22139. /**
  22140. * Gets a boolean defining if the target contains texture coordinates data
  22141. */
  22142. readonly hasUVs: boolean;
  22143. /**
  22144. * Affects position data to this target
  22145. * @param data defines the position data to use
  22146. */
  22147. setPositions(data: Nullable<FloatArray>): void;
  22148. /**
  22149. * Gets the position data stored in this target
  22150. * @returns a FloatArray containing the position data (or null if not present)
  22151. */
  22152. getPositions(): Nullable<FloatArray>;
  22153. /**
  22154. * Affects normal data to this target
  22155. * @param data defines the normal data to use
  22156. */
  22157. setNormals(data: Nullable<FloatArray>): void;
  22158. /**
  22159. * Gets the normal data stored in this target
  22160. * @returns a FloatArray containing the normal data (or null if not present)
  22161. */
  22162. getNormals(): Nullable<FloatArray>;
  22163. /**
  22164. * Affects tangent data to this target
  22165. * @param data defines the tangent data to use
  22166. */
  22167. setTangents(data: Nullable<FloatArray>): void;
  22168. /**
  22169. * Gets the tangent data stored in this target
  22170. * @returns a FloatArray containing the tangent data (or null if not present)
  22171. */
  22172. getTangents(): Nullable<FloatArray>;
  22173. /**
  22174. * Affects texture coordinates data to this target
  22175. * @param data defines the texture coordinates data to use
  22176. */
  22177. setUVs(data: Nullable<FloatArray>): void;
  22178. /**
  22179. * Gets the texture coordinates data stored in this target
  22180. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22181. */
  22182. getUVs(): Nullable<FloatArray>;
  22183. /**
  22184. * Serializes the current target into a Serialization object
  22185. * @returns the serialized object
  22186. */
  22187. serialize(): any;
  22188. /**
  22189. * Returns the string "MorphTarget"
  22190. * @returns "MorphTarget"
  22191. */
  22192. getClassName(): string;
  22193. /**
  22194. * Creates a new target from serialized data
  22195. * @param serializationObject defines the serialized data to use
  22196. * @returns a new MorphTarget
  22197. */
  22198. static Parse(serializationObject: any): MorphTarget;
  22199. /**
  22200. * Creates a MorphTarget from mesh data
  22201. * @param mesh defines the source mesh
  22202. * @param name defines the name to use for the new target
  22203. * @param influence defines the influence to attach to the target
  22204. * @returns a new MorphTarget
  22205. */
  22206. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22207. }
  22208. }
  22209. declare module BABYLON {
  22210. /**
  22211. * This class is used to deform meshes using morphing between different targets
  22212. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22213. */
  22214. export class MorphTargetManager {
  22215. private _targets;
  22216. private _targetInfluenceChangedObservers;
  22217. private _targetDataLayoutChangedObservers;
  22218. private _activeTargets;
  22219. private _scene;
  22220. private _influences;
  22221. private _supportsNormals;
  22222. private _supportsTangents;
  22223. private _supportsUVs;
  22224. private _vertexCount;
  22225. private _uniqueId;
  22226. private _tempInfluences;
  22227. /**
  22228. * Gets or sets a boolean indicating if normals must be morphed
  22229. */
  22230. enableNormalMorphing: boolean;
  22231. /**
  22232. * Gets or sets a boolean indicating if tangents must be morphed
  22233. */
  22234. enableTangentMorphing: boolean;
  22235. /**
  22236. * Gets or sets a boolean indicating if UV must be morphed
  22237. */
  22238. enableUVMorphing: boolean;
  22239. /**
  22240. * Creates a new MorphTargetManager
  22241. * @param scene defines the current scene
  22242. */
  22243. constructor(scene?: Nullable<Scene>);
  22244. /**
  22245. * Gets the unique ID of this manager
  22246. */
  22247. readonly uniqueId: number;
  22248. /**
  22249. * Gets the number of vertices handled by this manager
  22250. */
  22251. readonly vertexCount: number;
  22252. /**
  22253. * Gets a boolean indicating if this manager supports morphing of normals
  22254. */
  22255. readonly supportsNormals: boolean;
  22256. /**
  22257. * Gets a boolean indicating if this manager supports morphing of tangents
  22258. */
  22259. readonly supportsTangents: boolean;
  22260. /**
  22261. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22262. */
  22263. readonly supportsUVs: boolean;
  22264. /**
  22265. * Gets the number of targets stored in this manager
  22266. */
  22267. readonly numTargets: number;
  22268. /**
  22269. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22270. */
  22271. readonly numInfluencers: number;
  22272. /**
  22273. * Gets the list of influences (one per target)
  22274. */
  22275. readonly influences: Float32Array;
  22276. /**
  22277. * Gets the active target at specified index. An active target is a target with an influence > 0
  22278. * @param index defines the index to check
  22279. * @returns the requested target
  22280. */
  22281. getActiveTarget(index: number): MorphTarget;
  22282. /**
  22283. * Gets the target at specified index
  22284. * @param index defines the index to check
  22285. * @returns the requested target
  22286. */
  22287. getTarget(index: number): MorphTarget;
  22288. /**
  22289. * Add a new target to this manager
  22290. * @param target defines the target to add
  22291. */
  22292. addTarget(target: MorphTarget): void;
  22293. /**
  22294. * Removes a target from the manager
  22295. * @param target defines the target to remove
  22296. */
  22297. removeTarget(target: MorphTarget): void;
  22298. /**
  22299. * Serializes the current manager into a Serialization object
  22300. * @returns the serialized object
  22301. */
  22302. serialize(): any;
  22303. private _syncActiveTargets;
  22304. /**
  22305. * Syncrhonize the targets with all the meshes using this morph target manager
  22306. */
  22307. synchronize(): void;
  22308. /**
  22309. * Creates a new MorphTargetManager from serialized data
  22310. * @param serializationObject defines the serialized data
  22311. * @param scene defines the hosting scene
  22312. * @returns the new MorphTargetManager
  22313. */
  22314. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22315. }
  22316. }
  22317. declare module BABYLON {
  22318. /**
  22319. * Class used to represent a specific level of detail of a mesh
  22320. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22321. */
  22322. export class MeshLODLevel {
  22323. /** Defines the distance where this level should start being displayed */
  22324. distance: number;
  22325. /** Defines the mesh to use to render this level */
  22326. mesh: Nullable<Mesh>;
  22327. /**
  22328. * Creates a new LOD level
  22329. * @param distance defines the distance where this level should star being displayed
  22330. * @param mesh defines the mesh to use to render this level
  22331. */
  22332. constructor(
  22333. /** Defines the distance where this level should start being displayed */
  22334. distance: number,
  22335. /** Defines the mesh to use to render this level */
  22336. mesh: Nullable<Mesh>);
  22337. }
  22338. }
  22339. declare module BABYLON {
  22340. /**
  22341. * Mesh representing the gorund
  22342. */
  22343. export class GroundMesh extends Mesh {
  22344. /** If octree should be generated */
  22345. generateOctree: boolean;
  22346. private _heightQuads;
  22347. /** @hidden */
  22348. _subdivisionsX: number;
  22349. /** @hidden */
  22350. _subdivisionsY: number;
  22351. /** @hidden */
  22352. _width: number;
  22353. /** @hidden */
  22354. _height: number;
  22355. /** @hidden */
  22356. _minX: number;
  22357. /** @hidden */
  22358. _maxX: number;
  22359. /** @hidden */
  22360. _minZ: number;
  22361. /** @hidden */
  22362. _maxZ: number;
  22363. constructor(name: string, scene: Scene);
  22364. /**
  22365. * "GroundMesh"
  22366. * @returns "GroundMesh"
  22367. */
  22368. getClassName(): string;
  22369. /**
  22370. * The minimum of x and y subdivisions
  22371. */
  22372. readonly subdivisions: number;
  22373. /**
  22374. * X subdivisions
  22375. */
  22376. readonly subdivisionsX: number;
  22377. /**
  22378. * Y subdivisions
  22379. */
  22380. readonly subdivisionsY: number;
  22381. /**
  22382. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22383. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22384. * @param chunksCount the number of subdivisions for x and y
  22385. * @param octreeBlocksSize (Default: 32)
  22386. */
  22387. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22388. /**
  22389. * Returns a height (y) value in the Worl system :
  22390. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22391. * @param x x coordinate
  22392. * @param z z coordinate
  22393. * @returns the ground y position if (x, z) are outside the ground surface.
  22394. */
  22395. getHeightAtCoordinates(x: number, z: number): number;
  22396. /**
  22397. * Returns a normalized vector (Vector3) orthogonal to the ground
  22398. * at the ground coordinates (x, z) expressed in the World system.
  22399. * @param x x coordinate
  22400. * @param z z coordinate
  22401. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22402. */
  22403. getNormalAtCoordinates(x: number, z: number): Vector3;
  22404. /**
  22405. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22406. * at the ground coordinates (x, z) expressed in the World system.
  22407. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22408. * @param x x coordinate
  22409. * @param z z coordinate
  22410. * @param ref vector to store the result
  22411. * @returns the GroundMesh.
  22412. */
  22413. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22414. /**
  22415. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22416. * if the ground has been updated.
  22417. * This can be used in the render loop.
  22418. * @returns the GroundMesh.
  22419. */
  22420. updateCoordinateHeights(): GroundMesh;
  22421. private _getFacetAt;
  22422. private _initHeightQuads;
  22423. private _computeHeightQuads;
  22424. /**
  22425. * Serializes this ground mesh
  22426. * @param serializationObject object to write serialization to
  22427. */
  22428. serialize(serializationObject: any): void;
  22429. /**
  22430. * Parses a serialized ground mesh
  22431. * @param parsedMesh the serialized mesh
  22432. * @param scene the scene to create the ground mesh in
  22433. * @returns the created ground mesh
  22434. */
  22435. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22436. }
  22437. }
  22438. declare module BABYLON {
  22439. /**
  22440. * Interface for Physics-Joint data
  22441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22442. */
  22443. export interface PhysicsJointData {
  22444. /**
  22445. * The main pivot of the joint
  22446. */
  22447. mainPivot?: Vector3;
  22448. /**
  22449. * The connected pivot of the joint
  22450. */
  22451. connectedPivot?: Vector3;
  22452. /**
  22453. * The main axis of the joint
  22454. */
  22455. mainAxis?: Vector3;
  22456. /**
  22457. * The connected axis of the joint
  22458. */
  22459. connectedAxis?: Vector3;
  22460. /**
  22461. * The collision of the joint
  22462. */
  22463. collision?: boolean;
  22464. /**
  22465. * Native Oimo/Cannon/Energy data
  22466. */
  22467. nativeParams?: any;
  22468. }
  22469. /**
  22470. * This is a holder class for the physics joint created by the physics plugin
  22471. * It holds a set of functions to control the underlying joint
  22472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22473. */
  22474. export class PhysicsJoint {
  22475. /**
  22476. * The type of the physics joint
  22477. */
  22478. type: number;
  22479. /**
  22480. * The data for the physics joint
  22481. */
  22482. jointData: PhysicsJointData;
  22483. private _physicsJoint;
  22484. protected _physicsPlugin: IPhysicsEnginePlugin;
  22485. /**
  22486. * Initializes the physics joint
  22487. * @param type The type of the physics joint
  22488. * @param jointData The data for the physics joint
  22489. */
  22490. constructor(
  22491. /**
  22492. * The type of the physics joint
  22493. */
  22494. type: number,
  22495. /**
  22496. * The data for the physics joint
  22497. */
  22498. jointData: PhysicsJointData);
  22499. /**
  22500. * Gets the physics joint
  22501. */
  22502. /**
  22503. * Sets the physics joint
  22504. */
  22505. physicsJoint: any;
  22506. /**
  22507. * Sets the physics plugin
  22508. */
  22509. physicsPlugin: IPhysicsEnginePlugin;
  22510. /**
  22511. * Execute a function that is physics-plugin specific.
  22512. * @param {Function} func the function that will be executed.
  22513. * It accepts two parameters: the physics world and the physics joint
  22514. */
  22515. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22516. /**
  22517. * Distance-Joint type
  22518. */
  22519. static DistanceJoint: number;
  22520. /**
  22521. * Hinge-Joint type
  22522. */
  22523. static HingeJoint: number;
  22524. /**
  22525. * Ball-and-Socket joint type
  22526. */
  22527. static BallAndSocketJoint: number;
  22528. /**
  22529. * Wheel-Joint type
  22530. */
  22531. static WheelJoint: number;
  22532. /**
  22533. * Slider-Joint type
  22534. */
  22535. static SliderJoint: number;
  22536. /**
  22537. * Prismatic-Joint type
  22538. */
  22539. static PrismaticJoint: number;
  22540. /**
  22541. * Universal-Joint type
  22542. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22543. */
  22544. static UniversalJoint: number;
  22545. /**
  22546. * Hinge-Joint 2 type
  22547. */
  22548. static Hinge2Joint: number;
  22549. /**
  22550. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22551. */
  22552. static PointToPointJoint: number;
  22553. /**
  22554. * Spring-Joint type
  22555. */
  22556. static SpringJoint: number;
  22557. /**
  22558. * Lock-Joint type
  22559. */
  22560. static LockJoint: number;
  22561. }
  22562. /**
  22563. * A class representing a physics distance joint
  22564. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22565. */
  22566. export class DistanceJoint extends PhysicsJoint {
  22567. /**
  22568. *
  22569. * @param jointData The data for the Distance-Joint
  22570. */
  22571. constructor(jointData: DistanceJointData);
  22572. /**
  22573. * Update the predefined distance.
  22574. * @param maxDistance The maximum preferred distance
  22575. * @param minDistance The minimum preferred distance
  22576. */
  22577. updateDistance(maxDistance: number, minDistance?: number): void;
  22578. }
  22579. /**
  22580. * Represents a Motor-Enabled Joint
  22581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22582. */
  22583. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22584. /**
  22585. * Initializes the Motor-Enabled Joint
  22586. * @param type The type of the joint
  22587. * @param jointData The physica joint data for the joint
  22588. */
  22589. constructor(type: number, jointData: PhysicsJointData);
  22590. /**
  22591. * Set the motor values.
  22592. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22593. * @param force the force to apply
  22594. * @param maxForce max force for this motor.
  22595. */
  22596. setMotor(force?: number, maxForce?: number): void;
  22597. /**
  22598. * Set the motor's limits.
  22599. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22600. * @param upperLimit The upper limit of the motor
  22601. * @param lowerLimit The lower limit of the motor
  22602. */
  22603. setLimit(upperLimit: number, lowerLimit?: number): void;
  22604. }
  22605. /**
  22606. * This class represents a single physics Hinge-Joint
  22607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22608. */
  22609. export class HingeJoint extends MotorEnabledJoint {
  22610. /**
  22611. * Initializes the Hinge-Joint
  22612. * @param jointData The joint data for the Hinge-Joint
  22613. */
  22614. constructor(jointData: PhysicsJointData);
  22615. /**
  22616. * Set the motor values.
  22617. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22618. * @param {number} force the force to apply
  22619. * @param {number} maxForce max force for this motor.
  22620. */
  22621. setMotor(force?: number, maxForce?: number): void;
  22622. /**
  22623. * Set the motor's limits.
  22624. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22625. * @param upperLimit The upper limit of the motor
  22626. * @param lowerLimit The lower limit of the motor
  22627. */
  22628. setLimit(upperLimit: number, lowerLimit?: number): void;
  22629. }
  22630. /**
  22631. * This class represents a dual hinge physics joint (same as wheel joint)
  22632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22633. */
  22634. export class Hinge2Joint extends MotorEnabledJoint {
  22635. /**
  22636. * Initializes the Hinge2-Joint
  22637. * @param jointData The joint data for the Hinge2-Joint
  22638. */
  22639. constructor(jointData: PhysicsJointData);
  22640. /**
  22641. * Set the motor values.
  22642. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22643. * @param {number} targetSpeed the speed the motor is to reach
  22644. * @param {number} maxForce max force for this motor.
  22645. * @param {motorIndex} the motor's index, 0 or 1.
  22646. */
  22647. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22648. /**
  22649. * Set the motor limits.
  22650. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22651. * @param {number} upperLimit the upper limit
  22652. * @param {number} lowerLimit lower limit
  22653. * @param {motorIndex} the motor's index, 0 or 1.
  22654. */
  22655. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22656. }
  22657. /**
  22658. * Interface for a motor enabled joint
  22659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22660. */
  22661. export interface IMotorEnabledJoint {
  22662. /**
  22663. * Physics joint
  22664. */
  22665. physicsJoint: any;
  22666. /**
  22667. * Sets the motor of the motor-enabled joint
  22668. * @param force The force of the motor
  22669. * @param maxForce The maximum force of the motor
  22670. * @param motorIndex The index of the motor
  22671. */
  22672. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22673. /**
  22674. * Sets the limit of the motor
  22675. * @param upperLimit The upper limit of the motor
  22676. * @param lowerLimit The lower limit of the motor
  22677. * @param motorIndex The index of the motor
  22678. */
  22679. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22680. }
  22681. /**
  22682. * Joint data for a Distance-Joint
  22683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22684. */
  22685. export interface DistanceJointData extends PhysicsJointData {
  22686. /**
  22687. * Max distance the 2 joint objects can be apart
  22688. */
  22689. maxDistance: number;
  22690. }
  22691. /**
  22692. * Joint data from a spring joint
  22693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22694. */
  22695. export interface SpringJointData extends PhysicsJointData {
  22696. /**
  22697. * Length of the spring
  22698. */
  22699. length: number;
  22700. /**
  22701. * Stiffness of the spring
  22702. */
  22703. stiffness: number;
  22704. /**
  22705. * Damping of the spring
  22706. */
  22707. damping: number;
  22708. /** this callback will be called when applying the force to the impostors. */
  22709. forceApplicationCallback: () => void;
  22710. }
  22711. }
  22712. declare module BABYLON {
  22713. /**
  22714. * Holds the data for the raycast result
  22715. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22716. */
  22717. export class PhysicsRaycastResult {
  22718. private _hasHit;
  22719. private _hitDistance;
  22720. private _hitNormalWorld;
  22721. private _hitPointWorld;
  22722. private _rayFromWorld;
  22723. private _rayToWorld;
  22724. /**
  22725. * Gets if there was a hit
  22726. */
  22727. readonly hasHit: boolean;
  22728. /**
  22729. * Gets the distance from the hit
  22730. */
  22731. readonly hitDistance: number;
  22732. /**
  22733. * Gets the hit normal/direction in the world
  22734. */
  22735. readonly hitNormalWorld: Vector3;
  22736. /**
  22737. * Gets the hit point in the world
  22738. */
  22739. readonly hitPointWorld: Vector3;
  22740. /**
  22741. * Gets the ray "start point" of the ray in the world
  22742. */
  22743. readonly rayFromWorld: Vector3;
  22744. /**
  22745. * Gets the ray "end point" of the ray in the world
  22746. */
  22747. readonly rayToWorld: Vector3;
  22748. /**
  22749. * Sets the hit data (normal & point in world space)
  22750. * @param hitNormalWorld defines the normal in world space
  22751. * @param hitPointWorld defines the point in world space
  22752. */
  22753. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22754. /**
  22755. * Sets the distance from the start point to the hit point
  22756. * @param distance
  22757. */
  22758. setHitDistance(distance: number): void;
  22759. /**
  22760. * Calculates the distance manually
  22761. */
  22762. calculateHitDistance(): void;
  22763. /**
  22764. * Resets all the values to default
  22765. * @param from The from point on world space
  22766. * @param to The to point on world space
  22767. */
  22768. reset(from?: Vector3, to?: Vector3): void;
  22769. }
  22770. /**
  22771. * Interface for the size containing width and height
  22772. */
  22773. interface IXYZ {
  22774. /**
  22775. * X
  22776. */
  22777. x: number;
  22778. /**
  22779. * Y
  22780. */
  22781. y: number;
  22782. /**
  22783. * Z
  22784. */
  22785. z: number;
  22786. }
  22787. }
  22788. declare module BABYLON {
  22789. /**
  22790. * Interface used to describe a physics joint
  22791. */
  22792. export interface PhysicsImpostorJoint {
  22793. /** Defines the main impostor to which the joint is linked */
  22794. mainImpostor: PhysicsImpostor;
  22795. /** Defines the impostor that is connected to the main impostor using this joint */
  22796. connectedImpostor: PhysicsImpostor;
  22797. /** Defines the joint itself */
  22798. joint: PhysicsJoint;
  22799. }
  22800. /** @hidden */
  22801. export interface IPhysicsEnginePlugin {
  22802. world: any;
  22803. name: string;
  22804. setGravity(gravity: Vector3): void;
  22805. setTimeStep(timeStep: number): void;
  22806. getTimeStep(): number;
  22807. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22808. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22809. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22810. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22811. removePhysicsBody(impostor: PhysicsImpostor): void;
  22812. generateJoint(joint: PhysicsImpostorJoint): void;
  22813. removeJoint(joint: PhysicsImpostorJoint): void;
  22814. isSupported(): boolean;
  22815. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22816. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22817. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22818. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22819. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22820. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22821. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22822. getBodyMass(impostor: PhysicsImpostor): number;
  22823. getBodyFriction(impostor: PhysicsImpostor): number;
  22824. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22825. getBodyRestitution(impostor: PhysicsImpostor): number;
  22826. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22827. getBodyPressure?(impostor: PhysicsImpostor): number;
  22828. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22829. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22830. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22831. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22832. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22833. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22834. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22835. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22836. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22837. sleepBody(impostor: PhysicsImpostor): void;
  22838. wakeUpBody(impostor: PhysicsImpostor): void;
  22839. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22840. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22841. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22842. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22843. getRadius(impostor: PhysicsImpostor): number;
  22844. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22845. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22846. dispose(): void;
  22847. }
  22848. /**
  22849. * Interface used to define a physics engine
  22850. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22851. */
  22852. export interface IPhysicsEngine {
  22853. /**
  22854. * Gets the gravity vector used by the simulation
  22855. */
  22856. gravity: Vector3;
  22857. /**
  22858. * Sets the gravity vector used by the simulation
  22859. * @param gravity defines the gravity vector to use
  22860. */
  22861. setGravity(gravity: Vector3): void;
  22862. /**
  22863. * Set the time step of the physics engine.
  22864. * Default is 1/60.
  22865. * To slow it down, enter 1/600 for example.
  22866. * To speed it up, 1/30
  22867. * @param newTimeStep the new timestep to apply to this world.
  22868. */
  22869. setTimeStep(newTimeStep: number): void;
  22870. /**
  22871. * Get the time step of the physics engine.
  22872. * @returns the current time step
  22873. */
  22874. getTimeStep(): number;
  22875. /**
  22876. * Release all resources
  22877. */
  22878. dispose(): void;
  22879. /**
  22880. * Gets the name of the current physics plugin
  22881. * @returns the name of the plugin
  22882. */
  22883. getPhysicsPluginName(): string;
  22884. /**
  22885. * Adding a new impostor for the impostor tracking.
  22886. * This will be done by the impostor itself.
  22887. * @param impostor the impostor to add
  22888. */
  22889. addImpostor(impostor: PhysicsImpostor): void;
  22890. /**
  22891. * Remove an impostor from the engine.
  22892. * This impostor and its mesh will not longer be updated by the physics engine.
  22893. * @param impostor the impostor to remove
  22894. */
  22895. removeImpostor(impostor: PhysicsImpostor): void;
  22896. /**
  22897. * Add a joint to the physics engine
  22898. * @param mainImpostor defines the main impostor to which the joint is added.
  22899. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22900. * @param joint defines the joint that will connect both impostors.
  22901. */
  22902. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22903. /**
  22904. * Removes a joint from the simulation
  22905. * @param mainImpostor defines the impostor used with the joint
  22906. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22907. * @param joint defines the joint to remove
  22908. */
  22909. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22910. /**
  22911. * Gets the current plugin used to run the simulation
  22912. * @returns current plugin
  22913. */
  22914. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22915. /**
  22916. * Gets the list of physic impostors
  22917. * @returns an array of PhysicsImpostor
  22918. */
  22919. getImpostors(): Array<PhysicsImpostor>;
  22920. /**
  22921. * Gets the impostor for a physics enabled object
  22922. * @param object defines the object impersonated by the impostor
  22923. * @returns the PhysicsImpostor or null if not found
  22924. */
  22925. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22926. /**
  22927. * Gets the impostor for a physics body object
  22928. * @param body defines physics body used by the impostor
  22929. * @returns the PhysicsImpostor or null if not found
  22930. */
  22931. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22932. /**
  22933. * Does a raycast in the physics world
  22934. * @param from when should the ray start?
  22935. * @param to when should the ray end?
  22936. * @returns PhysicsRaycastResult
  22937. */
  22938. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22939. /**
  22940. * Called by the scene. No need to call it.
  22941. * @param delta defines the timespam between frames
  22942. */
  22943. _step(delta: number): void;
  22944. }
  22945. }
  22946. declare module BABYLON {
  22947. /**
  22948. * The interface for the physics imposter parameters
  22949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22950. */
  22951. export interface PhysicsImpostorParameters {
  22952. /**
  22953. * The mass of the physics imposter
  22954. */
  22955. mass: number;
  22956. /**
  22957. * The friction of the physics imposter
  22958. */
  22959. friction?: number;
  22960. /**
  22961. * The coefficient of restitution of the physics imposter
  22962. */
  22963. restitution?: number;
  22964. /**
  22965. * The native options of the physics imposter
  22966. */
  22967. nativeOptions?: any;
  22968. /**
  22969. * Specifies if the parent should be ignored
  22970. */
  22971. ignoreParent?: boolean;
  22972. /**
  22973. * Specifies if bi-directional transformations should be disabled
  22974. */
  22975. disableBidirectionalTransformation?: boolean;
  22976. /**
  22977. * The pressure inside the physics imposter, soft object only
  22978. */
  22979. pressure?: number;
  22980. /**
  22981. * The stiffness the physics imposter, soft object only
  22982. */
  22983. stiffness?: number;
  22984. /**
  22985. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22986. */
  22987. velocityIterations?: number;
  22988. /**
  22989. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22990. */
  22991. positionIterations?: number;
  22992. /**
  22993. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22994. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22995. * Add to fix multiple points
  22996. */
  22997. fixedPoints?: number;
  22998. /**
  22999. * The collision margin around a soft object
  23000. */
  23001. margin?: number;
  23002. /**
  23003. * The collision margin around a soft object
  23004. */
  23005. damping?: number;
  23006. /**
  23007. * The path for a rope based on an extrusion
  23008. */
  23009. path?: any;
  23010. /**
  23011. * The shape of an extrusion used for a rope based on an extrusion
  23012. */
  23013. shape?: any;
  23014. }
  23015. /**
  23016. * Interface for a physics-enabled object
  23017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23018. */
  23019. export interface IPhysicsEnabledObject {
  23020. /**
  23021. * The position of the physics-enabled object
  23022. */
  23023. position: Vector3;
  23024. /**
  23025. * The rotation of the physics-enabled object
  23026. */
  23027. rotationQuaternion: Nullable<Quaternion>;
  23028. /**
  23029. * The scale of the physics-enabled object
  23030. */
  23031. scaling: Vector3;
  23032. /**
  23033. * The rotation of the physics-enabled object
  23034. */
  23035. rotation?: Vector3;
  23036. /**
  23037. * The parent of the physics-enabled object
  23038. */
  23039. parent?: any;
  23040. /**
  23041. * The bounding info of the physics-enabled object
  23042. * @returns The bounding info of the physics-enabled object
  23043. */
  23044. getBoundingInfo(): BoundingInfo;
  23045. /**
  23046. * Computes the world matrix
  23047. * @param force Specifies if the world matrix should be computed by force
  23048. * @returns A world matrix
  23049. */
  23050. computeWorldMatrix(force: boolean): Matrix;
  23051. /**
  23052. * Gets the world matrix
  23053. * @returns A world matrix
  23054. */
  23055. getWorldMatrix?(): Matrix;
  23056. /**
  23057. * Gets the child meshes
  23058. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23059. * @returns An array of abstract meshes
  23060. */
  23061. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23062. /**
  23063. * Gets the vertex data
  23064. * @param kind The type of vertex data
  23065. * @returns A nullable array of numbers, or a float32 array
  23066. */
  23067. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23068. /**
  23069. * Gets the indices from the mesh
  23070. * @returns A nullable array of index arrays
  23071. */
  23072. getIndices?(): Nullable<IndicesArray>;
  23073. /**
  23074. * Gets the scene from the mesh
  23075. * @returns the indices array or null
  23076. */
  23077. getScene?(): Scene;
  23078. /**
  23079. * Gets the absolute position from the mesh
  23080. * @returns the absolute position
  23081. */
  23082. getAbsolutePosition(): Vector3;
  23083. /**
  23084. * Gets the absolute pivot point from the mesh
  23085. * @returns the absolute pivot point
  23086. */
  23087. getAbsolutePivotPoint(): Vector3;
  23088. /**
  23089. * Rotates the mesh
  23090. * @param axis The axis of rotation
  23091. * @param amount The amount of rotation
  23092. * @param space The space of the rotation
  23093. * @returns The rotation transform node
  23094. */
  23095. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23096. /**
  23097. * Translates the mesh
  23098. * @param axis The axis of translation
  23099. * @param distance The distance of translation
  23100. * @param space The space of the translation
  23101. * @returns The transform node
  23102. */
  23103. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23104. /**
  23105. * Sets the absolute position of the mesh
  23106. * @param absolutePosition The absolute position of the mesh
  23107. * @returns The transform node
  23108. */
  23109. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23110. /**
  23111. * Gets the class name of the mesh
  23112. * @returns The class name
  23113. */
  23114. getClassName(): string;
  23115. }
  23116. /**
  23117. * Represents a physics imposter
  23118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23119. */
  23120. export class PhysicsImpostor {
  23121. /**
  23122. * The physics-enabled object used as the physics imposter
  23123. */
  23124. object: IPhysicsEnabledObject;
  23125. /**
  23126. * The type of the physics imposter
  23127. */
  23128. type: number;
  23129. private _options;
  23130. private _scene?;
  23131. /**
  23132. * The default object size of the imposter
  23133. */
  23134. static DEFAULT_OBJECT_SIZE: Vector3;
  23135. /**
  23136. * The identity quaternion of the imposter
  23137. */
  23138. static IDENTITY_QUATERNION: Quaternion;
  23139. /** @hidden */
  23140. _pluginData: any;
  23141. private _physicsEngine;
  23142. private _physicsBody;
  23143. private _bodyUpdateRequired;
  23144. private _onBeforePhysicsStepCallbacks;
  23145. private _onAfterPhysicsStepCallbacks;
  23146. /** @hidden */
  23147. _onPhysicsCollideCallbacks: Array<{
  23148. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23149. otherImpostors: Array<PhysicsImpostor>;
  23150. }>;
  23151. private _deltaPosition;
  23152. private _deltaRotation;
  23153. private _deltaRotationConjugated;
  23154. /** @hidden */
  23155. _isFromLine: boolean;
  23156. private _parent;
  23157. private _isDisposed;
  23158. private static _tmpVecs;
  23159. private static _tmpQuat;
  23160. /**
  23161. * Specifies if the physics imposter is disposed
  23162. */
  23163. readonly isDisposed: boolean;
  23164. /**
  23165. * Gets the mass of the physics imposter
  23166. */
  23167. mass: number;
  23168. /**
  23169. * Gets the coefficient of friction
  23170. */
  23171. /**
  23172. * Sets the coefficient of friction
  23173. */
  23174. friction: number;
  23175. /**
  23176. * Gets the coefficient of restitution
  23177. */
  23178. /**
  23179. * Sets the coefficient of restitution
  23180. */
  23181. restitution: number;
  23182. /**
  23183. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23184. */
  23185. /**
  23186. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23187. */
  23188. pressure: number;
  23189. /**
  23190. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23191. */
  23192. /**
  23193. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23194. */
  23195. stiffness: number;
  23196. /**
  23197. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23198. */
  23199. /**
  23200. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23201. */
  23202. velocityIterations: number;
  23203. /**
  23204. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23205. */
  23206. /**
  23207. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23208. */
  23209. positionIterations: number;
  23210. /**
  23211. * The unique id of the physics imposter
  23212. * set by the physics engine when adding this impostor to the array
  23213. */
  23214. uniqueId: number;
  23215. /**
  23216. * @hidden
  23217. */
  23218. soft: boolean;
  23219. /**
  23220. * @hidden
  23221. */
  23222. segments: number;
  23223. private _joints;
  23224. /**
  23225. * Initializes the physics imposter
  23226. * @param object The physics-enabled object used as the physics imposter
  23227. * @param type The type of the physics imposter
  23228. * @param _options The options for the physics imposter
  23229. * @param _scene The Babylon scene
  23230. */
  23231. constructor(
  23232. /**
  23233. * The physics-enabled object used as the physics imposter
  23234. */
  23235. object: IPhysicsEnabledObject,
  23236. /**
  23237. * The type of the physics imposter
  23238. */
  23239. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23240. /**
  23241. * This function will completly initialize this impostor.
  23242. * It will create a new body - but only if this mesh has no parent.
  23243. * If it has, this impostor will not be used other than to define the impostor
  23244. * of the child mesh.
  23245. * @hidden
  23246. */
  23247. _init(): void;
  23248. private _getPhysicsParent;
  23249. /**
  23250. * Should a new body be generated.
  23251. * @returns boolean specifying if body initialization is required
  23252. */
  23253. isBodyInitRequired(): boolean;
  23254. /**
  23255. * Sets the updated scaling
  23256. * @param updated Specifies if the scaling is updated
  23257. */
  23258. setScalingUpdated(): void;
  23259. /**
  23260. * Force a regeneration of this or the parent's impostor's body.
  23261. * Use under cautious - This will remove all joints already implemented.
  23262. */
  23263. forceUpdate(): void;
  23264. /**
  23265. * Gets the body that holds this impostor. Either its own, or its parent.
  23266. */
  23267. /**
  23268. * Set the physics body. Used mainly by the physics engine/plugin
  23269. */
  23270. physicsBody: any;
  23271. /**
  23272. * Get the parent of the physics imposter
  23273. * @returns Physics imposter or null
  23274. */
  23275. /**
  23276. * Sets the parent of the physics imposter
  23277. */
  23278. parent: Nullable<PhysicsImpostor>;
  23279. /**
  23280. * Resets the update flags
  23281. */
  23282. resetUpdateFlags(): void;
  23283. /**
  23284. * Gets the object extend size
  23285. * @returns the object extend size
  23286. */
  23287. getObjectExtendSize(): Vector3;
  23288. /**
  23289. * Gets the object center
  23290. * @returns The object center
  23291. */
  23292. getObjectCenter(): Vector3;
  23293. /**
  23294. * Get a specific parametes from the options parameter
  23295. * @param paramName The object parameter name
  23296. * @returns The object parameter
  23297. */
  23298. getParam(paramName: string): any;
  23299. /**
  23300. * Sets a specific parameter in the options given to the physics plugin
  23301. * @param paramName The parameter name
  23302. * @param value The value of the parameter
  23303. */
  23304. setParam(paramName: string, value: number): void;
  23305. /**
  23306. * Specifically change the body's mass option. Won't recreate the physics body object
  23307. * @param mass The mass of the physics imposter
  23308. */
  23309. setMass(mass: number): void;
  23310. /**
  23311. * Gets the linear velocity
  23312. * @returns linear velocity or null
  23313. */
  23314. getLinearVelocity(): Nullable<Vector3>;
  23315. /**
  23316. * Sets the linear velocity
  23317. * @param velocity linear velocity or null
  23318. */
  23319. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23320. /**
  23321. * Gets the angular velocity
  23322. * @returns angular velocity or null
  23323. */
  23324. getAngularVelocity(): Nullable<Vector3>;
  23325. /**
  23326. * Sets the angular velocity
  23327. * @param velocity The velocity or null
  23328. */
  23329. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23330. /**
  23331. * Execute a function with the physics plugin native code
  23332. * Provide a function the will have two variables - the world object and the physics body object
  23333. * @param func The function to execute with the physics plugin native code
  23334. */
  23335. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23336. /**
  23337. * Register a function that will be executed before the physics world is stepping forward
  23338. * @param func The function to execute before the physics world is stepped forward
  23339. */
  23340. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23341. /**
  23342. * Unregister a function that will be executed before the physics world is stepping forward
  23343. * @param func The function to execute before the physics world is stepped forward
  23344. */
  23345. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23346. /**
  23347. * Register a function that will be executed after the physics step
  23348. * @param func The function to execute after physics step
  23349. */
  23350. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23351. /**
  23352. * Unregisters a function that will be executed after the physics step
  23353. * @param func The function to execute after physics step
  23354. */
  23355. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23356. /**
  23357. * register a function that will be executed when this impostor collides against a different body
  23358. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23359. * @param func Callback that is executed on collision
  23360. */
  23361. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23362. /**
  23363. * Unregisters the physics imposter on contact
  23364. * @param collideAgainst The physics object to collide against
  23365. * @param func Callback to execute on collision
  23366. */
  23367. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23368. private _tmpQuat;
  23369. private _tmpQuat2;
  23370. /**
  23371. * Get the parent rotation
  23372. * @returns The parent rotation
  23373. */
  23374. getParentsRotation(): Quaternion;
  23375. /**
  23376. * this function is executed by the physics engine.
  23377. */
  23378. beforeStep: () => void;
  23379. /**
  23380. * this function is executed by the physics engine
  23381. */
  23382. afterStep: () => void;
  23383. /**
  23384. * Legacy collision detection event support
  23385. */
  23386. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23387. /**
  23388. * event and body object due to cannon's event-based architecture.
  23389. */
  23390. onCollide: (e: {
  23391. body: any;
  23392. }) => void;
  23393. /**
  23394. * Apply a force
  23395. * @param force The force to apply
  23396. * @param contactPoint The contact point for the force
  23397. * @returns The physics imposter
  23398. */
  23399. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23400. /**
  23401. * Apply an impulse
  23402. * @param force The impulse force
  23403. * @param contactPoint The contact point for the impulse force
  23404. * @returns The physics imposter
  23405. */
  23406. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23407. /**
  23408. * A help function to create a joint
  23409. * @param otherImpostor A physics imposter used to create a joint
  23410. * @param jointType The type of joint
  23411. * @param jointData The data for the joint
  23412. * @returns The physics imposter
  23413. */
  23414. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23415. /**
  23416. * Add a joint to this impostor with a different impostor
  23417. * @param otherImpostor A physics imposter used to add a joint
  23418. * @param joint The joint to add
  23419. * @returns The physics imposter
  23420. */
  23421. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23422. /**
  23423. * Add an anchor to a cloth impostor
  23424. * @param otherImpostor rigid impostor to anchor to
  23425. * @param width ratio across width from 0 to 1
  23426. * @param height ratio up height from 0 to 1
  23427. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23428. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23429. * @returns impostor the soft imposter
  23430. */
  23431. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23432. /**
  23433. * Add a hook to a rope impostor
  23434. * @param otherImpostor rigid impostor to anchor to
  23435. * @param length ratio across rope from 0 to 1
  23436. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23437. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23438. * @returns impostor the rope imposter
  23439. */
  23440. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23441. /**
  23442. * Will keep this body still, in a sleep mode.
  23443. * @returns the physics imposter
  23444. */
  23445. sleep(): PhysicsImpostor;
  23446. /**
  23447. * Wake the body up.
  23448. * @returns The physics imposter
  23449. */
  23450. wakeUp(): PhysicsImpostor;
  23451. /**
  23452. * Clones the physics imposter
  23453. * @param newObject The physics imposter clones to this physics-enabled object
  23454. * @returns A nullable physics imposter
  23455. */
  23456. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23457. /**
  23458. * Disposes the physics imposter
  23459. */
  23460. dispose(): void;
  23461. /**
  23462. * Sets the delta position
  23463. * @param position The delta position amount
  23464. */
  23465. setDeltaPosition(position: Vector3): void;
  23466. /**
  23467. * Sets the delta rotation
  23468. * @param rotation The delta rotation amount
  23469. */
  23470. setDeltaRotation(rotation: Quaternion): void;
  23471. /**
  23472. * Gets the box size of the physics imposter and stores the result in the input parameter
  23473. * @param result Stores the box size
  23474. * @returns The physics imposter
  23475. */
  23476. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23477. /**
  23478. * Gets the radius of the physics imposter
  23479. * @returns Radius of the physics imposter
  23480. */
  23481. getRadius(): number;
  23482. /**
  23483. * Sync a bone with this impostor
  23484. * @param bone The bone to sync to the impostor.
  23485. * @param boneMesh The mesh that the bone is influencing.
  23486. * @param jointPivot The pivot of the joint / bone in local space.
  23487. * @param distToJoint Optional distance from the impostor to the joint.
  23488. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23489. */
  23490. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23491. /**
  23492. * Sync impostor to a bone
  23493. * @param bone The bone that the impostor will be synced to.
  23494. * @param boneMesh The mesh that the bone is influencing.
  23495. * @param jointPivot The pivot of the joint / bone in local space.
  23496. * @param distToJoint Optional distance from the impostor to the joint.
  23497. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23498. * @param boneAxis Optional vector3 axis the bone is aligned with
  23499. */
  23500. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23501. /**
  23502. * No-Imposter type
  23503. */
  23504. static NoImpostor: number;
  23505. /**
  23506. * Sphere-Imposter type
  23507. */
  23508. static SphereImpostor: number;
  23509. /**
  23510. * Box-Imposter type
  23511. */
  23512. static BoxImpostor: number;
  23513. /**
  23514. * Plane-Imposter type
  23515. */
  23516. static PlaneImpostor: number;
  23517. /**
  23518. * Mesh-imposter type
  23519. */
  23520. static MeshImpostor: number;
  23521. /**
  23522. * Capsule-Impostor type (Ammo.js plugin only)
  23523. */
  23524. static CapsuleImpostor: number;
  23525. /**
  23526. * Cylinder-Imposter type
  23527. */
  23528. static CylinderImpostor: number;
  23529. /**
  23530. * Particle-Imposter type
  23531. */
  23532. static ParticleImpostor: number;
  23533. /**
  23534. * Heightmap-Imposter type
  23535. */
  23536. static HeightmapImpostor: number;
  23537. /**
  23538. * ConvexHull-Impostor type (Ammo.js plugin only)
  23539. */
  23540. static ConvexHullImpostor: number;
  23541. /**
  23542. * Rope-Imposter type
  23543. */
  23544. static RopeImpostor: number;
  23545. /**
  23546. * Cloth-Imposter type
  23547. */
  23548. static ClothImpostor: number;
  23549. /**
  23550. * Softbody-Imposter type
  23551. */
  23552. static SoftbodyImpostor: number;
  23553. }
  23554. }
  23555. declare module BABYLON {
  23556. /**
  23557. * @hidden
  23558. **/
  23559. export class _CreationDataStorage {
  23560. closePath?: boolean;
  23561. closeArray?: boolean;
  23562. idx: number[];
  23563. dashSize: number;
  23564. gapSize: number;
  23565. path3D: Path3D;
  23566. pathArray: Vector3[][];
  23567. arc: number;
  23568. radius: number;
  23569. cap: number;
  23570. tessellation: number;
  23571. }
  23572. /**
  23573. * @hidden
  23574. **/
  23575. class _InstanceDataStorage {
  23576. visibleInstances: any;
  23577. batchCache: _InstancesBatch;
  23578. instancesBufferSize: number;
  23579. instancesBuffer: Nullable<Buffer>;
  23580. instancesData: Float32Array;
  23581. overridenInstanceCount: number;
  23582. isFrozen: boolean;
  23583. previousBatch: Nullable<_InstancesBatch>;
  23584. hardwareInstancedRendering: boolean;
  23585. sideOrientation: number;
  23586. }
  23587. /**
  23588. * @hidden
  23589. **/
  23590. export class _InstancesBatch {
  23591. mustReturn: boolean;
  23592. visibleInstances: Nullable<InstancedMesh[]>[];
  23593. renderSelf: boolean[];
  23594. hardwareInstancedRendering: boolean[];
  23595. }
  23596. /**
  23597. * Class used to represent renderable models
  23598. */
  23599. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23600. /**
  23601. * Mesh side orientation : usually the external or front surface
  23602. */
  23603. static readonly FRONTSIDE: number;
  23604. /**
  23605. * Mesh side orientation : usually the internal or back surface
  23606. */
  23607. static readonly BACKSIDE: number;
  23608. /**
  23609. * Mesh side orientation : both internal and external or front and back surfaces
  23610. */
  23611. static readonly DOUBLESIDE: number;
  23612. /**
  23613. * Mesh side orientation : by default, `FRONTSIDE`
  23614. */
  23615. static readonly DEFAULTSIDE: number;
  23616. /**
  23617. * Mesh cap setting : no cap
  23618. */
  23619. static readonly NO_CAP: number;
  23620. /**
  23621. * Mesh cap setting : one cap at the beginning of the mesh
  23622. */
  23623. static readonly CAP_START: number;
  23624. /**
  23625. * Mesh cap setting : one cap at the end of the mesh
  23626. */
  23627. static readonly CAP_END: number;
  23628. /**
  23629. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23630. */
  23631. static readonly CAP_ALL: number;
  23632. /**
  23633. * Mesh pattern setting : no flip or rotate
  23634. */
  23635. static readonly NO_FLIP: number;
  23636. /**
  23637. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23638. */
  23639. static readonly FLIP_TILE: number;
  23640. /**
  23641. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23642. */
  23643. static readonly ROTATE_TILE: number;
  23644. /**
  23645. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23646. */
  23647. static readonly FLIP_ROW: number;
  23648. /**
  23649. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23650. */
  23651. static readonly ROTATE_ROW: number;
  23652. /**
  23653. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23654. */
  23655. static readonly FLIP_N_ROTATE_TILE: number;
  23656. /**
  23657. * Mesh pattern setting : rotate pattern and rotate
  23658. */
  23659. static readonly FLIP_N_ROTATE_ROW: number;
  23660. /**
  23661. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23662. */
  23663. static readonly CENTER: number;
  23664. /**
  23665. * Mesh tile positioning : part tiles on left
  23666. */
  23667. static readonly LEFT: number;
  23668. /**
  23669. * Mesh tile positioning : part tiles on right
  23670. */
  23671. static readonly RIGHT: number;
  23672. /**
  23673. * Mesh tile positioning : part tiles on top
  23674. */
  23675. static readonly TOP: number;
  23676. /**
  23677. * Mesh tile positioning : part tiles on bottom
  23678. */
  23679. static readonly BOTTOM: number;
  23680. /**
  23681. * Gets the default side orientation.
  23682. * @param orientation the orientation to value to attempt to get
  23683. * @returns the default orientation
  23684. * @hidden
  23685. */
  23686. static _GetDefaultSideOrientation(orientation?: number): number;
  23687. private _internalMeshDataInfo;
  23688. /**
  23689. * An event triggered before rendering the mesh
  23690. */
  23691. readonly onBeforeRenderObservable: Observable<Mesh>;
  23692. /**
  23693. * An event triggered before binding the mesh
  23694. */
  23695. readonly onBeforeBindObservable: Observable<Mesh>;
  23696. /**
  23697. * An event triggered after rendering the mesh
  23698. */
  23699. readonly onAfterRenderObservable: Observable<Mesh>;
  23700. /**
  23701. * An event triggered before drawing the mesh
  23702. */
  23703. readonly onBeforeDrawObservable: Observable<Mesh>;
  23704. private _onBeforeDrawObserver;
  23705. /**
  23706. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23707. */
  23708. onBeforeDraw: () => void;
  23709. readonly hasInstances: boolean;
  23710. /**
  23711. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23712. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23713. */
  23714. delayLoadState: number;
  23715. /**
  23716. * Gets the list of instances created from this mesh
  23717. * it is not supposed to be modified manually.
  23718. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23719. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23720. */
  23721. instances: InstancedMesh[];
  23722. /**
  23723. * Gets the file containing delay loading data for this mesh
  23724. */
  23725. delayLoadingFile: string;
  23726. /** @hidden */
  23727. _binaryInfo: any;
  23728. /**
  23729. * User defined function used to change how LOD level selection is done
  23730. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23731. */
  23732. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23733. /**
  23734. * Gets or sets the morph target manager
  23735. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23736. */
  23737. morphTargetManager: Nullable<MorphTargetManager>;
  23738. /** @hidden */
  23739. _creationDataStorage: Nullable<_CreationDataStorage>;
  23740. /** @hidden */
  23741. _geometry: Nullable<Geometry>;
  23742. /** @hidden */
  23743. _delayInfo: Array<string>;
  23744. /** @hidden */
  23745. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23746. /** @hidden */
  23747. _instanceDataStorage: _InstanceDataStorage;
  23748. private _effectiveMaterial;
  23749. /** @hidden */
  23750. _shouldGenerateFlatShading: boolean;
  23751. /** @hidden */
  23752. _originalBuilderSideOrientation: number;
  23753. /**
  23754. * Use this property to change the original side orientation defined at construction time
  23755. */
  23756. overrideMaterialSideOrientation: Nullable<number>;
  23757. /**
  23758. * Gets the source mesh (the one used to clone this one from)
  23759. */
  23760. readonly source: Nullable<Mesh>;
  23761. /**
  23762. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23763. */
  23764. isUnIndexed: boolean;
  23765. /**
  23766. * @constructor
  23767. * @param name The value used by scene.getMeshByName() to do a lookup.
  23768. * @param scene The scene to add this mesh to.
  23769. * @param parent The parent of this mesh, if it has one
  23770. * @param source An optional Mesh from which geometry is shared, cloned.
  23771. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23772. * When false, achieved by calling a clone(), also passing False.
  23773. * This will make creation of children, recursive.
  23774. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23775. */
  23776. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23777. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23778. /**
  23779. * Gets the class name
  23780. * @returns the string "Mesh".
  23781. */
  23782. getClassName(): string;
  23783. /** @hidden */
  23784. readonly _isMesh: boolean;
  23785. /**
  23786. * Returns a description of this mesh
  23787. * @param fullDetails define if full details about this mesh must be used
  23788. * @returns a descriptive string representing this mesh
  23789. */
  23790. toString(fullDetails?: boolean): string;
  23791. /** @hidden */
  23792. _unBindEffect(): void;
  23793. /**
  23794. * Gets a boolean indicating if this mesh has LOD
  23795. */
  23796. readonly hasLODLevels: boolean;
  23797. /**
  23798. * Gets the list of MeshLODLevel associated with the current mesh
  23799. * @returns an array of MeshLODLevel
  23800. */
  23801. getLODLevels(): MeshLODLevel[];
  23802. private _sortLODLevels;
  23803. /**
  23804. * Add a mesh as LOD level triggered at the given distance.
  23805. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23806. * @param distance The distance from the center of the object to show this level
  23807. * @param mesh The mesh to be added as LOD level (can be null)
  23808. * @return This mesh (for chaining)
  23809. */
  23810. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23811. /**
  23812. * Returns the LOD level mesh at the passed distance or null if not found.
  23813. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23814. * @param distance The distance from the center of the object to show this level
  23815. * @returns a Mesh or `null`
  23816. */
  23817. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23818. /**
  23819. * Remove a mesh from the LOD array
  23820. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23821. * @param mesh defines the mesh to be removed
  23822. * @return This mesh (for chaining)
  23823. */
  23824. removeLODLevel(mesh: Mesh): Mesh;
  23825. /**
  23826. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23827. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23828. * @param camera defines the camera to use to compute distance
  23829. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23830. * @return This mesh (for chaining)
  23831. */
  23832. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23833. /**
  23834. * Gets the mesh internal Geometry object
  23835. */
  23836. readonly geometry: Nullable<Geometry>;
  23837. /**
  23838. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23839. * @returns the total number of vertices
  23840. */
  23841. getTotalVertices(): number;
  23842. /**
  23843. * Returns the content of an associated vertex buffer
  23844. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23845. * - VertexBuffer.PositionKind
  23846. * - VertexBuffer.UVKind
  23847. * - VertexBuffer.UV2Kind
  23848. * - VertexBuffer.UV3Kind
  23849. * - VertexBuffer.UV4Kind
  23850. * - VertexBuffer.UV5Kind
  23851. * - VertexBuffer.UV6Kind
  23852. * - VertexBuffer.ColorKind
  23853. * - VertexBuffer.MatricesIndicesKind
  23854. * - VertexBuffer.MatricesIndicesExtraKind
  23855. * - VertexBuffer.MatricesWeightsKind
  23856. * - VertexBuffer.MatricesWeightsExtraKind
  23857. * @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
  23858. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23859. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23860. */
  23861. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23862. /**
  23863. * Returns the mesh VertexBuffer object from the requested `kind`
  23864. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23865. * - VertexBuffer.PositionKind
  23866. * - VertexBuffer.NormalKind
  23867. * - VertexBuffer.UVKind
  23868. * - VertexBuffer.UV2Kind
  23869. * - VertexBuffer.UV3Kind
  23870. * - VertexBuffer.UV4Kind
  23871. * - VertexBuffer.UV5Kind
  23872. * - VertexBuffer.UV6Kind
  23873. * - VertexBuffer.ColorKind
  23874. * - VertexBuffer.MatricesIndicesKind
  23875. * - VertexBuffer.MatricesIndicesExtraKind
  23876. * - VertexBuffer.MatricesWeightsKind
  23877. * - VertexBuffer.MatricesWeightsExtraKind
  23878. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23879. */
  23880. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23881. /**
  23882. * Tests if a specific vertex buffer is associated with this mesh
  23883. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23884. * - VertexBuffer.PositionKind
  23885. * - VertexBuffer.NormalKind
  23886. * - VertexBuffer.UVKind
  23887. * - VertexBuffer.UV2Kind
  23888. * - VertexBuffer.UV3Kind
  23889. * - VertexBuffer.UV4Kind
  23890. * - VertexBuffer.UV5Kind
  23891. * - VertexBuffer.UV6Kind
  23892. * - VertexBuffer.ColorKind
  23893. * - VertexBuffer.MatricesIndicesKind
  23894. * - VertexBuffer.MatricesIndicesExtraKind
  23895. * - VertexBuffer.MatricesWeightsKind
  23896. * - VertexBuffer.MatricesWeightsExtraKind
  23897. * @returns a boolean
  23898. */
  23899. isVerticesDataPresent(kind: string): boolean;
  23900. /**
  23901. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23902. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23903. * - VertexBuffer.PositionKind
  23904. * - VertexBuffer.UVKind
  23905. * - VertexBuffer.UV2Kind
  23906. * - VertexBuffer.UV3Kind
  23907. * - VertexBuffer.UV4Kind
  23908. * - VertexBuffer.UV5Kind
  23909. * - VertexBuffer.UV6Kind
  23910. * - VertexBuffer.ColorKind
  23911. * - VertexBuffer.MatricesIndicesKind
  23912. * - VertexBuffer.MatricesIndicesExtraKind
  23913. * - VertexBuffer.MatricesWeightsKind
  23914. * - VertexBuffer.MatricesWeightsExtraKind
  23915. * @returns a boolean
  23916. */
  23917. isVertexBufferUpdatable(kind: string): boolean;
  23918. /**
  23919. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23920. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23921. * - VertexBuffer.PositionKind
  23922. * - VertexBuffer.NormalKind
  23923. * - VertexBuffer.UVKind
  23924. * - VertexBuffer.UV2Kind
  23925. * - VertexBuffer.UV3Kind
  23926. * - VertexBuffer.UV4Kind
  23927. * - VertexBuffer.UV5Kind
  23928. * - VertexBuffer.UV6Kind
  23929. * - VertexBuffer.ColorKind
  23930. * - VertexBuffer.MatricesIndicesKind
  23931. * - VertexBuffer.MatricesIndicesExtraKind
  23932. * - VertexBuffer.MatricesWeightsKind
  23933. * - VertexBuffer.MatricesWeightsExtraKind
  23934. * @returns an array of strings
  23935. */
  23936. getVerticesDataKinds(): string[];
  23937. /**
  23938. * Returns a positive integer : the total number of indices in this mesh geometry.
  23939. * @returns the numner of indices or zero if the mesh has no geometry.
  23940. */
  23941. getTotalIndices(): number;
  23942. /**
  23943. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23944. * @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.
  23945. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23946. * @returns the indices array or an empty array if the mesh has no geometry
  23947. */
  23948. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23949. readonly isBlocked: boolean;
  23950. /**
  23951. * Determine if the current mesh is ready to be rendered
  23952. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23953. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23954. * @returns true if all associated assets are ready (material, textures, shaders)
  23955. */
  23956. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23957. /**
  23958. * 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.
  23959. */
  23960. readonly areNormalsFrozen: boolean;
  23961. /**
  23962. * 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.
  23963. * @returns the current mesh
  23964. */
  23965. freezeNormals(): Mesh;
  23966. /**
  23967. * 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
  23968. * @returns the current mesh
  23969. */
  23970. unfreezeNormals(): Mesh;
  23971. /**
  23972. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23973. */
  23974. overridenInstanceCount: number;
  23975. /** @hidden */
  23976. _preActivate(): Mesh;
  23977. /** @hidden */
  23978. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23979. /** @hidden */
  23980. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23981. /**
  23982. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23983. * This means the mesh underlying bounding box and sphere are recomputed.
  23984. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23985. * @returns the current mesh
  23986. */
  23987. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23988. /** @hidden */
  23989. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23990. /**
  23991. * This function will subdivide the mesh into multiple submeshes
  23992. * @param count defines the expected number of submeshes
  23993. */
  23994. subdivide(count: number): void;
  23995. /**
  23996. * Copy a FloatArray into a specific associated vertex buffer
  23997. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23998. * - VertexBuffer.PositionKind
  23999. * - VertexBuffer.UVKind
  24000. * - VertexBuffer.UV2Kind
  24001. * - VertexBuffer.UV3Kind
  24002. * - VertexBuffer.UV4Kind
  24003. * - VertexBuffer.UV5Kind
  24004. * - VertexBuffer.UV6Kind
  24005. * - VertexBuffer.ColorKind
  24006. * - VertexBuffer.MatricesIndicesKind
  24007. * - VertexBuffer.MatricesIndicesExtraKind
  24008. * - VertexBuffer.MatricesWeightsKind
  24009. * - VertexBuffer.MatricesWeightsExtraKind
  24010. * @param data defines the data source
  24011. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24012. * @param stride defines the data stride size (can be null)
  24013. * @returns the current mesh
  24014. */
  24015. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24016. /**
  24017. * Flags an associated vertex buffer as updatable
  24018. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24019. * - VertexBuffer.PositionKind
  24020. * - VertexBuffer.UVKind
  24021. * - VertexBuffer.UV2Kind
  24022. * - VertexBuffer.UV3Kind
  24023. * - VertexBuffer.UV4Kind
  24024. * - VertexBuffer.UV5Kind
  24025. * - VertexBuffer.UV6Kind
  24026. * - VertexBuffer.ColorKind
  24027. * - VertexBuffer.MatricesIndicesKind
  24028. * - VertexBuffer.MatricesIndicesExtraKind
  24029. * - VertexBuffer.MatricesWeightsKind
  24030. * - VertexBuffer.MatricesWeightsExtraKind
  24031. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24032. */
  24033. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24034. /**
  24035. * Sets the mesh global Vertex Buffer
  24036. * @param buffer defines the buffer to use
  24037. * @returns the current mesh
  24038. */
  24039. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24040. /**
  24041. * Update a specific associated vertex buffer
  24042. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24043. * - VertexBuffer.PositionKind
  24044. * - VertexBuffer.UVKind
  24045. * - VertexBuffer.UV2Kind
  24046. * - VertexBuffer.UV3Kind
  24047. * - VertexBuffer.UV4Kind
  24048. * - VertexBuffer.UV5Kind
  24049. * - VertexBuffer.UV6Kind
  24050. * - VertexBuffer.ColorKind
  24051. * - VertexBuffer.MatricesIndicesKind
  24052. * - VertexBuffer.MatricesIndicesExtraKind
  24053. * - VertexBuffer.MatricesWeightsKind
  24054. * - VertexBuffer.MatricesWeightsExtraKind
  24055. * @param data defines the data source
  24056. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24057. * @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)
  24058. * @returns the current mesh
  24059. */
  24060. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24061. /**
  24062. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24063. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24064. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24065. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24066. * @returns the current mesh
  24067. */
  24068. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24069. /**
  24070. * Creates a un-shared specific occurence of the geometry for the mesh.
  24071. * @returns the current mesh
  24072. */
  24073. makeGeometryUnique(): Mesh;
  24074. /**
  24075. * Set the index buffer of this mesh
  24076. * @param indices defines the source data
  24077. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24078. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24079. * @returns the current mesh
  24080. */
  24081. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24082. /**
  24083. * Update the current index buffer
  24084. * @param indices defines the source data
  24085. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24086. * @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)
  24087. * @returns the current mesh
  24088. */
  24089. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24090. /**
  24091. * Invert the geometry to move from a right handed system to a left handed one.
  24092. * @returns the current mesh
  24093. */
  24094. toLeftHanded(): Mesh;
  24095. /** @hidden */
  24096. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24097. /** @hidden */
  24098. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24099. /**
  24100. * Registers for this mesh a javascript function called just before the rendering process
  24101. * @param func defines the function to call before rendering this mesh
  24102. * @returns the current mesh
  24103. */
  24104. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24105. /**
  24106. * Disposes a previously registered javascript function called before the rendering
  24107. * @param func defines the function to remove
  24108. * @returns the current mesh
  24109. */
  24110. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24111. /**
  24112. * Registers for this mesh a javascript function called just after the rendering is complete
  24113. * @param func defines the function to call after rendering this mesh
  24114. * @returns the current mesh
  24115. */
  24116. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24117. /**
  24118. * Disposes a previously registered javascript function called after the rendering.
  24119. * @param func defines the function to remove
  24120. * @returns the current mesh
  24121. */
  24122. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24123. /** @hidden */
  24124. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24125. /** @hidden */
  24126. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24127. /** @hidden */
  24128. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24129. /** @hidden */
  24130. _rebuild(): void;
  24131. /** @hidden */
  24132. _freeze(): void;
  24133. /** @hidden */
  24134. _unFreeze(): void;
  24135. /**
  24136. * 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
  24137. * @param subMesh defines the subMesh to render
  24138. * @param enableAlphaMode defines if alpha mode can be changed
  24139. * @returns the current mesh
  24140. */
  24141. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24142. private _onBeforeDraw;
  24143. /**
  24144. * Renormalize the mesh and patch it up if there are no weights
  24145. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24146. * However in the case of zero weights then we set just a single influence to 1.
  24147. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24148. */
  24149. cleanMatrixWeights(): void;
  24150. private normalizeSkinFourWeights;
  24151. private normalizeSkinWeightsAndExtra;
  24152. /**
  24153. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24154. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24155. * the user know there was an issue with importing the mesh
  24156. * @returns a validation object with skinned, valid and report string
  24157. */
  24158. validateSkinning(): {
  24159. skinned: boolean;
  24160. valid: boolean;
  24161. report: string;
  24162. };
  24163. /** @hidden */
  24164. _checkDelayState(): Mesh;
  24165. private _queueLoad;
  24166. /**
  24167. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24168. * A mesh is in the frustum if its bounding box intersects the frustum
  24169. * @param frustumPlanes defines the frustum to test
  24170. * @returns true if the mesh is in the frustum planes
  24171. */
  24172. isInFrustum(frustumPlanes: Plane[]): boolean;
  24173. /**
  24174. * Sets the mesh material by the material or multiMaterial `id` property
  24175. * @param id is a string identifying the material or the multiMaterial
  24176. * @returns the current mesh
  24177. */
  24178. setMaterialByID(id: string): Mesh;
  24179. /**
  24180. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24181. * @returns an array of IAnimatable
  24182. */
  24183. getAnimatables(): IAnimatable[];
  24184. /**
  24185. * Modifies the mesh geometry according to the passed transformation matrix.
  24186. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24187. * The mesh normals are modified using the same transformation.
  24188. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24189. * @param transform defines the transform matrix to use
  24190. * @see http://doc.babylonjs.com/resources/baking_transformations
  24191. * @returns the current mesh
  24192. */
  24193. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24194. /**
  24195. * Modifies the mesh geometry according to its own current World Matrix.
  24196. * The mesh World Matrix is then reset.
  24197. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24198. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24199. * @see http://doc.babylonjs.com/resources/baking_transformations
  24200. * @returns the current mesh
  24201. */
  24202. bakeCurrentTransformIntoVertices(): Mesh;
  24203. /** @hidden */
  24204. readonly _positions: Nullable<Vector3[]>;
  24205. /** @hidden */
  24206. _resetPointsArrayCache(): Mesh;
  24207. /** @hidden */
  24208. _generatePointsArray(): boolean;
  24209. /**
  24210. * Returns a new Mesh object generated from the current mesh properties.
  24211. * This method must not get confused with createInstance()
  24212. * @param name is a string, the name given to the new mesh
  24213. * @param newParent can be any Node object (default `null`)
  24214. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24215. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24216. * @returns a new mesh
  24217. */
  24218. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24219. /**
  24220. * Releases resources associated with this mesh.
  24221. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24222. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24223. */
  24224. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24225. /**
  24226. * Modifies the mesh geometry according to a displacement map.
  24227. * 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.
  24228. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24229. * @param url is a string, the URL from the image file is to be downloaded.
  24230. * @param minHeight is the lower limit of the displacement.
  24231. * @param maxHeight is the upper limit of the displacement.
  24232. * @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.
  24233. * @param uvOffset is an optional vector2 used to offset UV.
  24234. * @param uvScale is an optional vector2 used to scale UV.
  24235. * @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.
  24236. * @returns the Mesh.
  24237. */
  24238. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24239. /**
  24240. * Modifies the mesh geometry according to a displacementMap buffer.
  24241. * 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.
  24242. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24243. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24244. * @param heightMapWidth is the width of the buffer image.
  24245. * @param heightMapHeight is the height of the buffer image.
  24246. * @param minHeight is the lower limit of the displacement.
  24247. * @param maxHeight is the upper limit of the displacement.
  24248. * @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.
  24249. * @param uvOffset is an optional vector2 used to offset UV.
  24250. * @param uvScale is an optional vector2 used to scale UV.
  24251. * @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.
  24252. * @returns the Mesh.
  24253. */
  24254. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24255. /**
  24256. * Modify the mesh to get a flat shading rendering.
  24257. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24258. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24259. * @returns current mesh
  24260. */
  24261. convertToFlatShadedMesh(): Mesh;
  24262. /**
  24263. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24264. * In other words, more vertices, no more indices and a single bigger VBO.
  24265. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24266. * @returns current mesh
  24267. */
  24268. convertToUnIndexedMesh(): Mesh;
  24269. /**
  24270. * Inverses facet orientations.
  24271. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24272. * @param flipNormals will also inverts the normals
  24273. * @returns current mesh
  24274. */
  24275. flipFaces(flipNormals?: boolean): Mesh;
  24276. /**
  24277. * Increase the number of facets and hence vertices in a mesh
  24278. * Vertex normals are interpolated from existing vertex normals
  24279. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24280. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24281. */
  24282. increaseVertices(numberPerEdge: number): void;
  24283. /**
  24284. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24285. * This will undo any application of covertToFlatShadedMesh
  24286. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24287. */
  24288. forceSharedVertices(): void;
  24289. /** @hidden */
  24290. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24291. /** @hidden */
  24292. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24293. /**
  24294. * Creates a new InstancedMesh object from the mesh model.
  24295. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24296. * @param name defines the name of the new instance
  24297. * @returns a new InstancedMesh
  24298. */
  24299. createInstance(name: string): InstancedMesh;
  24300. /**
  24301. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24302. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24303. * @returns the current mesh
  24304. */
  24305. synchronizeInstances(): Mesh;
  24306. /**
  24307. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24308. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24309. * This should be used together with the simplification to avoid disappearing triangles.
  24310. * @param successCallback an optional success callback to be called after the optimization finished.
  24311. * @returns the current mesh
  24312. */
  24313. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24314. /**
  24315. * Serialize current mesh
  24316. * @param serializationObject defines the object which will receive the serialization data
  24317. */
  24318. serialize(serializationObject: any): void;
  24319. /** @hidden */
  24320. _syncGeometryWithMorphTargetManager(): void;
  24321. /** @hidden */
  24322. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24323. /**
  24324. * Returns a new Mesh object parsed from the source provided.
  24325. * @param parsedMesh is the source
  24326. * @param scene defines the hosting scene
  24327. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24328. * @returns a new Mesh
  24329. */
  24330. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24331. /**
  24332. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24333. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24334. * @param name defines the name of the mesh to create
  24335. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24336. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24337. * @param closePath creates a seam between the first and the last points of each path of the path array
  24338. * @param offset is taken in account only if the `pathArray` is containing a single path
  24339. * @param scene defines the hosting scene
  24340. * @param updatable defines if the mesh must be flagged as updatable
  24341. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24342. * @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)
  24343. * @returns a new Mesh
  24344. */
  24345. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24346. /**
  24347. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24348. * @param name defines the name of the mesh to create
  24349. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24350. * @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
  24351. * @param scene defines the hosting scene
  24352. * @param updatable defines if the mesh must be flagged as updatable
  24353. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24354. * @returns a new Mesh
  24355. */
  24356. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24357. /**
  24358. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24359. * @param name defines the name of the mesh to create
  24360. * @param size sets the size (float) of each box side (default 1)
  24361. * @param scene defines the hosting scene
  24362. * @param updatable defines if the mesh must be flagged as updatable
  24363. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24364. * @returns a new Mesh
  24365. */
  24366. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24367. /**
  24368. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24369. * @param name defines the name of the mesh to create
  24370. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24371. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24372. * @param scene defines the hosting scene
  24373. * @param updatable defines if the mesh must be flagged as updatable
  24374. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24375. * @returns a new Mesh
  24376. */
  24377. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24378. /**
  24379. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24380. * @param name defines the name of the mesh to create
  24381. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24382. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24383. * @param scene defines the hosting scene
  24384. * @returns a new Mesh
  24385. */
  24386. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24387. /**
  24388. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24389. * @param name defines the name of the mesh to create
  24390. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24391. * @param diameterTop set the top cap diameter (floats, default 1)
  24392. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24393. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24394. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24395. * @param scene defines the hosting scene
  24396. * @param updatable defines if the mesh must be flagged as updatable
  24397. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24398. * @returns a new Mesh
  24399. */
  24400. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24401. /**
  24402. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24403. * @param name defines the name of the mesh to create
  24404. * @param diameter sets the diameter size (float) of the torus (default 1)
  24405. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24406. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24407. * @param scene defines the hosting scene
  24408. * @param updatable defines if the mesh must be flagged as updatable
  24409. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24410. * @returns a new Mesh
  24411. */
  24412. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24413. /**
  24414. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24415. * @param name defines the name of the mesh to create
  24416. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24417. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24418. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24419. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24420. * @param p the number of windings on X axis (positive integers, default 2)
  24421. * @param q the number of windings on Y axis (positive integers, default 3)
  24422. * @param scene defines the hosting scene
  24423. * @param updatable defines if the mesh must be flagged as updatable
  24424. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24425. * @returns a new Mesh
  24426. */
  24427. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24428. /**
  24429. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24430. * @param name defines the name of the mesh to create
  24431. * @param points is an array successive Vector3
  24432. * @param scene defines the hosting scene
  24433. * @param updatable defines if the mesh must be flagged as updatable
  24434. * @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).
  24435. * @returns a new Mesh
  24436. */
  24437. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24438. /**
  24439. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24440. * @param name defines the name of the mesh to create
  24441. * @param points is an array successive Vector3
  24442. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24443. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24444. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24445. * @param scene defines the hosting scene
  24446. * @param updatable defines if the mesh must be flagged as updatable
  24447. * @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)
  24448. * @returns a new Mesh
  24449. */
  24450. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24451. /**
  24452. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24453. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24454. * 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.
  24455. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24456. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24457. * Remember you can only change the shape positions, not their number when updating a polygon.
  24458. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24459. * @param name defines the name of the mesh to create
  24460. * @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
  24461. * @param scene defines the hosting scene
  24462. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24463. * @param updatable defines if the mesh must be flagged as updatable
  24464. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24465. * @param earcutInjection can be used to inject your own earcut reference
  24466. * @returns a new Mesh
  24467. */
  24468. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24469. /**
  24470. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24471. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24472. * @param name defines the name of the mesh to create
  24473. * @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
  24474. * @param depth defines the height of extrusion
  24475. * @param scene defines the hosting scene
  24476. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24477. * @param updatable defines if the mesh must be flagged as updatable
  24478. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24479. * @param earcutInjection can be used to inject your own earcut reference
  24480. * @returns a new Mesh
  24481. */
  24482. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24483. /**
  24484. * Creates an extruded shape mesh.
  24485. * 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
  24486. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24487. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24488. * @param name defines the name of the mesh to create
  24489. * @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
  24490. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24491. * @param scale is the value to scale the shape
  24492. * @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
  24493. * @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
  24494. * @param scene defines the hosting scene
  24495. * @param updatable defines if the mesh must be flagged as updatable
  24496. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24497. * @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)
  24498. * @returns a new Mesh
  24499. */
  24500. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24501. /**
  24502. * Creates an custom extruded shape mesh.
  24503. * The custom extrusion is a parametric shape.
  24504. * It has no predefined shape. Its final shape will depend on the input parameters.
  24505. * Please consider using the same method from the MeshBuilder class instead
  24506. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24507. * @param name defines the name of the mesh to create
  24508. * @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
  24509. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24510. * @param scaleFunction is a custom Javascript function called on each path point
  24511. * @param rotationFunction is a custom Javascript function called on each path point
  24512. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24513. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24514. * @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
  24515. * @param scene defines the hosting scene
  24516. * @param updatable defines if the mesh must be flagged as updatable
  24517. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24518. * @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)
  24519. * @returns a new Mesh
  24520. */
  24521. 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;
  24522. /**
  24523. * Creates lathe mesh.
  24524. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24525. * Please consider using the same method from the MeshBuilder class instead
  24526. * @param name defines the name of the mesh to create
  24527. * @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
  24528. * @param radius is the radius value of the lathe
  24529. * @param tessellation is the side number of the lathe.
  24530. * @param scene defines the hosting scene
  24531. * @param updatable defines if the mesh must be flagged as updatable
  24532. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24533. * @returns a new Mesh
  24534. */
  24535. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24536. /**
  24537. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24538. * @param name defines the name of the mesh to create
  24539. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24540. * @param scene defines the hosting scene
  24541. * @param updatable defines if the mesh must be flagged as updatable
  24542. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24543. * @returns a new Mesh
  24544. */
  24545. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24546. /**
  24547. * Creates a ground mesh.
  24548. * Please consider using the same method from the MeshBuilder class instead
  24549. * @param name defines the name of the mesh to create
  24550. * @param width set the width of the ground
  24551. * @param height set the height of the ground
  24552. * @param subdivisions sets the number of subdivisions per side
  24553. * @param scene defines the hosting scene
  24554. * @param updatable defines if the mesh must be flagged as updatable
  24555. * @returns a new Mesh
  24556. */
  24557. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24558. /**
  24559. * Creates a tiled ground mesh.
  24560. * Please consider using the same method from the MeshBuilder class instead
  24561. * @param name defines the name of the mesh to create
  24562. * @param xmin set the ground minimum X coordinate
  24563. * @param zmin set the ground minimum Y coordinate
  24564. * @param xmax set the ground maximum X coordinate
  24565. * @param zmax set the ground maximum Z coordinate
  24566. * @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
  24567. * @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
  24568. * @param scene defines the hosting scene
  24569. * @param updatable defines if the mesh must be flagged as updatable
  24570. * @returns a new Mesh
  24571. */
  24572. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24573. w: number;
  24574. h: number;
  24575. }, precision: {
  24576. w: number;
  24577. h: number;
  24578. }, scene: Scene, updatable?: boolean): Mesh;
  24579. /**
  24580. * Creates a ground mesh from a height map.
  24581. * Please consider using the same method from the MeshBuilder class instead
  24582. * @see http://doc.babylonjs.com/babylon101/height_map
  24583. * @param name defines the name of the mesh to create
  24584. * @param url sets the URL of the height map image resource
  24585. * @param width set the ground width size
  24586. * @param height set the ground height size
  24587. * @param subdivisions sets the number of subdivision per side
  24588. * @param minHeight is the minimum altitude on the ground
  24589. * @param maxHeight is the maximum altitude on the ground
  24590. * @param scene defines the hosting scene
  24591. * @param updatable defines if the mesh must be flagged as updatable
  24592. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24593. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24594. * @returns a new Mesh
  24595. */
  24596. 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;
  24597. /**
  24598. * Creates a tube mesh.
  24599. * The tube is a parametric shape.
  24600. * It has no predefined shape. Its final shape will depend on the input parameters.
  24601. * Please consider using the same method from the MeshBuilder class instead
  24602. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24603. * @param name defines the name of the mesh to create
  24604. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24605. * @param radius sets the tube radius size
  24606. * @param tessellation is the number of sides on the tubular surface
  24607. * @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
  24608. * @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
  24609. * @param scene defines the hosting scene
  24610. * @param updatable defines if the mesh must be flagged as updatable
  24611. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24612. * @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)
  24613. * @returns a new Mesh
  24614. */
  24615. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24616. (i: number, distance: number): number;
  24617. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24618. /**
  24619. * Creates a polyhedron mesh.
  24620. * Please consider using the same method from the MeshBuilder class instead.
  24621. * * 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
  24622. * * The parameter `size` (positive float, default 1) sets the polygon size
  24623. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24624. * * 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`
  24625. * * 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
  24626. * * 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)`)
  24627. * * 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
  24628. * * 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
  24629. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24630. * * 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
  24631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24632. * @param name defines the name of the mesh to create
  24633. * @param options defines the options used to create the mesh
  24634. * @param scene defines the hosting scene
  24635. * @returns a new Mesh
  24636. */
  24637. static CreatePolyhedron(name: string, options: {
  24638. type?: number;
  24639. size?: number;
  24640. sizeX?: number;
  24641. sizeY?: number;
  24642. sizeZ?: number;
  24643. custom?: any;
  24644. faceUV?: Vector4[];
  24645. faceColors?: Color4[];
  24646. updatable?: boolean;
  24647. sideOrientation?: number;
  24648. }, scene: Scene): Mesh;
  24649. /**
  24650. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24651. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24652. * * 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`)
  24653. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24654. * * 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
  24655. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24656. * * 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
  24657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24658. * @param name defines the name of the mesh
  24659. * @param options defines the options used to create the mesh
  24660. * @param scene defines the hosting scene
  24661. * @returns a new Mesh
  24662. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24663. */
  24664. static CreateIcoSphere(name: string, options: {
  24665. radius?: number;
  24666. flat?: boolean;
  24667. subdivisions?: number;
  24668. sideOrientation?: number;
  24669. updatable?: boolean;
  24670. }, scene: Scene): Mesh;
  24671. /**
  24672. * Creates a decal mesh.
  24673. * Please consider using the same method from the MeshBuilder class instead.
  24674. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24675. * @param name defines the name of the mesh
  24676. * @param sourceMesh defines the mesh receiving the decal
  24677. * @param position sets the position of the decal in world coordinates
  24678. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24679. * @param size sets the decal scaling
  24680. * @param angle sets the angle to rotate the decal
  24681. * @returns a new Mesh
  24682. */
  24683. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24684. /**
  24685. * Prepare internal position array for software CPU skinning
  24686. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24687. */
  24688. setPositionsForCPUSkinning(): Float32Array;
  24689. /**
  24690. * Prepare internal normal array for software CPU skinning
  24691. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24692. */
  24693. setNormalsForCPUSkinning(): Float32Array;
  24694. /**
  24695. * Updates the vertex buffer by applying transformation from the bones
  24696. * @param skeleton defines the skeleton to apply to current mesh
  24697. * @returns the current mesh
  24698. */
  24699. applySkeleton(skeleton: Skeleton): Mesh;
  24700. /**
  24701. * 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
  24702. * @param meshes defines the list of meshes to scan
  24703. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24704. */
  24705. static MinMax(meshes: AbstractMesh[]): {
  24706. min: Vector3;
  24707. max: Vector3;
  24708. };
  24709. /**
  24710. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24711. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24712. * @returns a vector3
  24713. */
  24714. static Center(meshesOrMinMaxVector: {
  24715. min: Vector3;
  24716. max: Vector3;
  24717. } | AbstractMesh[]): Vector3;
  24718. /**
  24719. * Merge the array of meshes into a single mesh for performance reasons.
  24720. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24721. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24722. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24723. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24724. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24725. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24726. * @returns a new mesh
  24727. */
  24728. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24729. /** @hidden */
  24730. addInstance(instance: InstancedMesh): void;
  24731. /** @hidden */
  24732. removeInstance(instance: InstancedMesh): void;
  24733. }
  24734. }
  24735. declare module BABYLON {
  24736. /**
  24737. * This is the base class of all the camera used in the application.
  24738. * @see http://doc.babylonjs.com/features/cameras
  24739. */
  24740. export class Camera extends Node {
  24741. /** @hidden */
  24742. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24743. /**
  24744. * This is the default projection mode used by the cameras.
  24745. * It helps recreating a feeling of perspective and better appreciate depth.
  24746. * This is the best way to simulate real life cameras.
  24747. */
  24748. static readonly PERSPECTIVE_CAMERA: number;
  24749. /**
  24750. * This helps creating camera with an orthographic mode.
  24751. * 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.
  24752. */
  24753. static readonly ORTHOGRAPHIC_CAMERA: number;
  24754. /**
  24755. * This is the default FOV mode for perspective cameras.
  24756. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24757. */
  24758. static readonly FOVMODE_VERTICAL_FIXED: number;
  24759. /**
  24760. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24761. */
  24762. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24763. /**
  24764. * This specifies ther is no need for a camera rig.
  24765. * Basically only one eye is rendered corresponding to the camera.
  24766. */
  24767. static readonly RIG_MODE_NONE: number;
  24768. /**
  24769. * Simulates a camera Rig with one blue eye and one red eye.
  24770. * This can be use with 3d blue and red glasses.
  24771. */
  24772. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24773. /**
  24774. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24775. */
  24776. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24777. /**
  24778. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24779. */
  24780. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24781. /**
  24782. * Defines that both eyes of the camera will be rendered over under each other.
  24783. */
  24784. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24785. /**
  24786. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24787. */
  24788. static readonly RIG_MODE_VR: number;
  24789. /**
  24790. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24791. */
  24792. static readonly RIG_MODE_WEBVR: number;
  24793. /**
  24794. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24795. */
  24796. static readonly RIG_MODE_CUSTOM: number;
  24797. /**
  24798. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24799. */
  24800. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24801. /**
  24802. * Define the input manager associated with the camera.
  24803. */
  24804. inputs: CameraInputsManager<Camera>;
  24805. /** @hidden */
  24806. _position: Vector3;
  24807. /**
  24808. * Define the current local position of the camera in the scene
  24809. */
  24810. position: Vector3;
  24811. /**
  24812. * The vector the camera should consider as up.
  24813. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24814. */
  24815. upVector: Vector3;
  24816. /**
  24817. * Define the current limit on the left side for an orthographic camera
  24818. * In scene unit
  24819. */
  24820. orthoLeft: Nullable<number>;
  24821. /**
  24822. * Define the current limit on the right side for an orthographic camera
  24823. * In scene unit
  24824. */
  24825. orthoRight: Nullable<number>;
  24826. /**
  24827. * Define the current limit on the bottom side for an orthographic camera
  24828. * In scene unit
  24829. */
  24830. orthoBottom: Nullable<number>;
  24831. /**
  24832. * Define the current limit on the top side for an orthographic camera
  24833. * In scene unit
  24834. */
  24835. orthoTop: Nullable<number>;
  24836. /**
  24837. * Field Of View is set in Radians. (default is 0.8)
  24838. */
  24839. fov: number;
  24840. /**
  24841. * Define the minimum distance the camera can see from.
  24842. * This is important to note that the depth buffer are not infinite and the closer it starts
  24843. * the more your scene might encounter depth fighting issue.
  24844. */
  24845. minZ: number;
  24846. /**
  24847. * Define the maximum distance the camera can see to.
  24848. * This is important to note that the depth buffer are not infinite and the further it end
  24849. * the more your scene might encounter depth fighting issue.
  24850. */
  24851. maxZ: number;
  24852. /**
  24853. * Define the default inertia of the camera.
  24854. * This helps giving a smooth feeling to the camera movement.
  24855. */
  24856. inertia: number;
  24857. /**
  24858. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24859. */
  24860. mode: number;
  24861. /**
  24862. * Define wether the camera is intermediate.
  24863. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24864. */
  24865. isIntermediate: boolean;
  24866. /**
  24867. * Define the viewport of the camera.
  24868. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24869. */
  24870. viewport: Viewport;
  24871. /**
  24872. * Restricts the camera to viewing objects with the same layerMask.
  24873. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24874. */
  24875. layerMask: number;
  24876. /**
  24877. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24878. */
  24879. fovMode: number;
  24880. /**
  24881. * Rig mode of the camera.
  24882. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24883. * This is normally controlled byt the camera themselves as internal use.
  24884. */
  24885. cameraRigMode: number;
  24886. /**
  24887. * Defines the distance between both "eyes" in case of a RIG
  24888. */
  24889. interaxialDistance: number;
  24890. /**
  24891. * Defines if stereoscopic rendering is done side by side or over under.
  24892. */
  24893. isStereoscopicSideBySide: boolean;
  24894. /**
  24895. * 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
  24896. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24897. * else in the scene. (Eg. security camera)
  24898. *
  24899. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  24900. */
  24901. customRenderTargets: RenderTargetTexture[];
  24902. /**
  24903. * When set, the camera will render to this render target instead of the default canvas
  24904. *
  24905. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24906. */
  24907. outputRenderTarget: Nullable<RenderTargetTexture>;
  24908. /**
  24909. * Observable triggered when the camera view matrix has changed.
  24910. */
  24911. onViewMatrixChangedObservable: Observable<Camera>;
  24912. /**
  24913. * Observable triggered when the camera Projection matrix has changed.
  24914. */
  24915. onProjectionMatrixChangedObservable: Observable<Camera>;
  24916. /**
  24917. * Observable triggered when the inputs have been processed.
  24918. */
  24919. onAfterCheckInputsObservable: Observable<Camera>;
  24920. /**
  24921. * Observable triggered when reset has been called and applied to the camera.
  24922. */
  24923. onRestoreStateObservable: Observable<Camera>;
  24924. /** @hidden */
  24925. _cameraRigParams: any;
  24926. /** @hidden */
  24927. _rigCameras: Camera[];
  24928. /** @hidden */
  24929. _rigPostProcess: Nullable<PostProcess>;
  24930. protected _webvrViewMatrix: Matrix;
  24931. /** @hidden */
  24932. _skipRendering: boolean;
  24933. /** @hidden */
  24934. _projectionMatrix: Matrix;
  24935. /** @hidden */
  24936. _postProcesses: Nullable<PostProcess>[];
  24937. /** @hidden */
  24938. _activeMeshes: SmartArray<AbstractMesh>;
  24939. protected _globalPosition: Vector3;
  24940. /** @hidden */
  24941. _computedViewMatrix: Matrix;
  24942. private _doNotComputeProjectionMatrix;
  24943. private _transformMatrix;
  24944. private _frustumPlanes;
  24945. private _refreshFrustumPlanes;
  24946. private _storedFov;
  24947. private _stateStored;
  24948. /**
  24949. * Instantiates a new camera object.
  24950. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24951. * @see http://doc.babylonjs.com/features/cameras
  24952. * @param name Defines the name of the camera in the scene
  24953. * @param position Defines the position of the camera
  24954. * @param scene Defines the scene the camera belongs too
  24955. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24956. */
  24957. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24958. /**
  24959. * Store current camera state (fov, position, etc..)
  24960. * @returns the camera
  24961. */
  24962. storeState(): Camera;
  24963. /**
  24964. * Restores the camera state values if it has been stored. You must call storeState() first
  24965. */
  24966. protected _restoreStateValues(): boolean;
  24967. /**
  24968. * Restored camera state. You must call storeState() first.
  24969. * @returns true if restored and false otherwise
  24970. */
  24971. restoreState(): boolean;
  24972. /**
  24973. * Gets the class name of the camera.
  24974. * @returns the class name
  24975. */
  24976. getClassName(): string;
  24977. /** @hidden */
  24978. readonly _isCamera: boolean;
  24979. /**
  24980. * Gets a string representation of the camera useful for debug purpose.
  24981. * @param fullDetails Defines that a more verboe level of logging is required
  24982. * @returns the string representation
  24983. */
  24984. toString(fullDetails?: boolean): string;
  24985. /**
  24986. * Gets the current world space position of the camera.
  24987. */
  24988. readonly globalPosition: Vector3;
  24989. /**
  24990. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24991. * @returns the active meshe list
  24992. */
  24993. getActiveMeshes(): SmartArray<AbstractMesh>;
  24994. /**
  24995. * Check wether a mesh is part of the current active mesh list of the camera
  24996. * @param mesh Defines the mesh to check
  24997. * @returns true if active, false otherwise
  24998. */
  24999. isActiveMesh(mesh: Mesh): boolean;
  25000. /**
  25001. * Is this camera ready to be used/rendered
  25002. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25003. * @return true if the camera is ready
  25004. */
  25005. isReady(completeCheck?: boolean): boolean;
  25006. /** @hidden */
  25007. _initCache(): void;
  25008. /** @hidden */
  25009. _updateCache(ignoreParentClass?: boolean): void;
  25010. /** @hidden */
  25011. _isSynchronized(): boolean;
  25012. /** @hidden */
  25013. _isSynchronizedViewMatrix(): boolean;
  25014. /** @hidden */
  25015. _isSynchronizedProjectionMatrix(): boolean;
  25016. /**
  25017. * Attach the input controls to a specific dom element to get the input from.
  25018. * @param element Defines the element the controls should be listened from
  25019. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25020. */
  25021. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25022. /**
  25023. * Detach the current controls from the specified dom element.
  25024. * @param element Defines the element to stop listening the inputs from
  25025. */
  25026. detachControl(element: HTMLElement): void;
  25027. /**
  25028. * Update the camera state according to the different inputs gathered during the frame.
  25029. */
  25030. update(): void;
  25031. /** @hidden */
  25032. _checkInputs(): void;
  25033. /** @hidden */
  25034. readonly rigCameras: Camera[];
  25035. /**
  25036. * Gets the post process used by the rig cameras
  25037. */
  25038. readonly rigPostProcess: Nullable<PostProcess>;
  25039. /**
  25040. * Internal, gets the first post proces.
  25041. * @returns the first post process to be run on this camera.
  25042. */
  25043. _getFirstPostProcess(): Nullable<PostProcess>;
  25044. private _cascadePostProcessesToRigCams;
  25045. /**
  25046. * Attach a post process to the camera.
  25047. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25048. * @param postProcess The post process to attach to the camera
  25049. * @param insertAt The position of the post process in case several of them are in use in the scene
  25050. * @returns the position the post process has been inserted at
  25051. */
  25052. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25053. /**
  25054. * Detach a post process to the camera.
  25055. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25056. * @param postProcess The post process to detach from the camera
  25057. */
  25058. detachPostProcess(postProcess: PostProcess): void;
  25059. /**
  25060. * Gets the current world matrix of the camera
  25061. */
  25062. getWorldMatrix(): Matrix;
  25063. /** @hidden */
  25064. _getViewMatrix(): Matrix;
  25065. /**
  25066. * Gets the current view matrix of the camera.
  25067. * @param force forces the camera to recompute the matrix without looking at the cached state
  25068. * @returns the view matrix
  25069. */
  25070. getViewMatrix(force?: boolean): Matrix;
  25071. /**
  25072. * Freeze the projection matrix.
  25073. * It will prevent the cache check of the camera projection compute and can speed up perf
  25074. * if no parameter of the camera are meant to change
  25075. * @param projection Defines manually a projection if necessary
  25076. */
  25077. freezeProjectionMatrix(projection?: Matrix): void;
  25078. /**
  25079. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25080. */
  25081. unfreezeProjectionMatrix(): void;
  25082. /**
  25083. * Gets the current projection matrix of the camera.
  25084. * @param force forces the camera to recompute the matrix without looking at the cached state
  25085. * @returns the projection matrix
  25086. */
  25087. getProjectionMatrix(force?: boolean): Matrix;
  25088. /**
  25089. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25090. * @returns a Matrix
  25091. */
  25092. getTransformationMatrix(): Matrix;
  25093. private _updateFrustumPlanes;
  25094. /**
  25095. * Checks if a cullable object (mesh...) is in the camera frustum
  25096. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25097. * @param target The object to check
  25098. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25099. * @returns true if the object is in frustum otherwise false
  25100. */
  25101. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25102. /**
  25103. * Checks if a cullable object (mesh...) is in the camera frustum
  25104. * Unlike isInFrustum this cheks the full bounding box
  25105. * @param target The object to check
  25106. * @returns true if the object is in frustum otherwise false
  25107. */
  25108. isCompletelyInFrustum(target: ICullable): boolean;
  25109. /**
  25110. * Gets a ray in the forward direction from the camera.
  25111. * @param length Defines the length of the ray to create
  25112. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25113. * @param origin Defines the start point of the ray which defaults to the camera position
  25114. * @returns the forward ray
  25115. */
  25116. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25117. /**
  25118. * Releases resources associated with this node.
  25119. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25120. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25121. */
  25122. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25123. /** @hidden */
  25124. _isLeftCamera: boolean;
  25125. /**
  25126. * Gets the left camera of a rig setup in case of Rigged Camera
  25127. */
  25128. readonly isLeftCamera: boolean;
  25129. /** @hidden */
  25130. _isRightCamera: boolean;
  25131. /**
  25132. * Gets the right camera of a rig setup in case of Rigged Camera
  25133. */
  25134. readonly isRightCamera: boolean;
  25135. /**
  25136. * Gets the left camera of a rig setup in case of Rigged Camera
  25137. */
  25138. readonly leftCamera: Nullable<FreeCamera>;
  25139. /**
  25140. * Gets the right camera of a rig setup in case of Rigged Camera
  25141. */
  25142. readonly rightCamera: Nullable<FreeCamera>;
  25143. /**
  25144. * Gets the left camera target of a rig setup in case of Rigged Camera
  25145. * @returns the target position
  25146. */
  25147. getLeftTarget(): Nullable<Vector3>;
  25148. /**
  25149. * Gets the right camera target of a rig setup in case of Rigged Camera
  25150. * @returns the target position
  25151. */
  25152. getRightTarget(): Nullable<Vector3>;
  25153. /**
  25154. * @hidden
  25155. */
  25156. setCameraRigMode(mode: number, rigParams: any): void;
  25157. /** @hidden */
  25158. static _setStereoscopicRigMode(camera: Camera): void;
  25159. /** @hidden */
  25160. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25161. /** @hidden */
  25162. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25163. /** @hidden */
  25164. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25165. /** @hidden */
  25166. _getVRProjectionMatrix(): Matrix;
  25167. protected _updateCameraRotationMatrix(): void;
  25168. protected _updateWebVRCameraRotationMatrix(): void;
  25169. /**
  25170. * This function MUST be overwritten by the different WebVR cameras available.
  25171. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25172. * @hidden
  25173. */
  25174. _getWebVRProjectionMatrix(): Matrix;
  25175. /**
  25176. * This function MUST be overwritten by the different WebVR cameras available.
  25177. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25178. * @hidden
  25179. */
  25180. _getWebVRViewMatrix(): Matrix;
  25181. /** @hidden */
  25182. setCameraRigParameter(name: string, value: any): void;
  25183. /**
  25184. * needs to be overridden by children so sub has required properties to be copied
  25185. * @hidden
  25186. */
  25187. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25188. /**
  25189. * May need to be overridden by children
  25190. * @hidden
  25191. */
  25192. _updateRigCameras(): void;
  25193. /** @hidden */
  25194. _setupInputs(): void;
  25195. /**
  25196. * Serialiaze the camera setup to a json represention
  25197. * @returns the JSON representation
  25198. */
  25199. serialize(): any;
  25200. /**
  25201. * Clones the current camera.
  25202. * @param name The cloned camera name
  25203. * @returns the cloned camera
  25204. */
  25205. clone(name: string): Camera;
  25206. /**
  25207. * Gets the direction of the camera relative to a given local axis.
  25208. * @param localAxis Defines the reference axis to provide a relative direction.
  25209. * @return the direction
  25210. */
  25211. getDirection(localAxis: Vector3): Vector3;
  25212. /**
  25213. * Returns the current camera absolute rotation
  25214. */
  25215. readonly absoluteRotation: Quaternion;
  25216. /**
  25217. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25218. * @param localAxis Defines the reference axis to provide a relative direction.
  25219. * @param result Defines the vector to store the result in
  25220. */
  25221. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25222. /**
  25223. * Gets a camera constructor for a given camera type
  25224. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25225. * @param name The name of the camera the result will be able to instantiate
  25226. * @param scene The scene the result will construct the camera in
  25227. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25228. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25229. * @returns a factory method to construc the camera
  25230. */
  25231. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25232. /**
  25233. * Compute the world matrix of the camera.
  25234. * @returns the camera workd matrix
  25235. */
  25236. computeWorldMatrix(): Matrix;
  25237. /**
  25238. * Parse a JSON and creates the camera from the parsed information
  25239. * @param parsedCamera The JSON to parse
  25240. * @param scene The scene to instantiate the camera in
  25241. * @returns the newly constructed camera
  25242. */
  25243. static Parse(parsedCamera: any, scene: Scene): Camera;
  25244. }
  25245. }
  25246. declare module BABYLON {
  25247. /**
  25248. * Class containing static functions to help procedurally build meshes
  25249. */
  25250. export class DiscBuilder {
  25251. /**
  25252. * Creates a plane polygonal mesh. By default, this is a disc
  25253. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25254. * * 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
  25255. * * 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
  25256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25257. * * 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
  25258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25259. * @param name defines the name of the mesh
  25260. * @param options defines the options used to create the mesh
  25261. * @param scene defines the hosting scene
  25262. * @returns the plane polygonal mesh
  25263. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25264. */
  25265. static CreateDisc(name: string, options: {
  25266. radius?: number;
  25267. tessellation?: number;
  25268. arc?: number;
  25269. updatable?: boolean;
  25270. sideOrientation?: number;
  25271. frontUVs?: Vector4;
  25272. backUVs?: Vector4;
  25273. }, scene?: Nullable<Scene>): Mesh;
  25274. }
  25275. }
  25276. declare module BABYLON {
  25277. /**
  25278. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25279. *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.
  25280. * The SPS is also a particle system. It provides some methods to manage the particles.
  25281. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25282. *
  25283. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25284. */
  25285. export class SolidParticleSystem implements IDisposable {
  25286. /**
  25287. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25288. * Example : var p = SPS.particles[i];
  25289. */
  25290. particles: SolidParticle[];
  25291. /**
  25292. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25293. */
  25294. nbParticles: number;
  25295. /**
  25296. * If the particles must ever face the camera (default false). Useful for planar particles.
  25297. */
  25298. billboard: boolean;
  25299. /**
  25300. * Recompute normals when adding a shape
  25301. */
  25302. recomputeNormals: boolean;
  25303. /**
  25304. * This a counter ofr your own usage. It's not set by any SPS functions.
  25305. */
  25306. counter: number;
  25307. /**
  25308. * The SPS name. This name is also given to the underlying mesh.
  25309. */
  25310. name: string;
  25311. /**
  25312. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25313. */
  25314. mesh: Mesh;
  25315. /**
  25316. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25317. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25318. */
  25319. vars: any;
  25320. /**
  25321. * This array is populated when the SPS is set as 'pickable'.
  25322. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25323. * Each element of this array is an object `{idx: int, faceId: int}`.
  25324. * `idx` is the picked particle index in the `SPS.particles` array
  25325. * `faceId` is the picked face index counted within this particle.
  25326. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25327. */
  25328. pickedParticles: {
  25329. idx: number;
  25330. faceId: number;
  25331. }[];
  25332. /**
  25333. * This array is populated when `enableDepthSort` is set to true.
  25334. * Each element of this array is an instance of the class DepthSortedParticle.
  25335. */
  25336. depthSortedParticles: DepthSortedParticle[];
  25337. /**
  25338. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25339. * @hidden
  25340. */
  25341. _bSphereOnly: boolean;
  25342. /**
  25343. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25344. * @hidden
  25345. */
  25346. _bSphereRadiusFactor: number;
  25347. private _scene;
  25348. private _positions;
  25349. private _indices;
  25350. private _normals;
  25351. private _colors;
  25352. private _uvs;
  25353. private _indices32;
  25354. private _positions32;
  25355. private _normals32;
  25356. private _fixedNormal32;
  25357. private _colors32;
  25358. private _uvs32;
  25359. private _index;
  25360. private _updatable;
  25361. private _pickable;
  25362. private _isVisibilityBoxLocked;
  25363. private _alwaysVisible;
  25364. private _depthSort;
  25365. private _shapeCounter;
  25366. private _copy;
  25367. private _color;
  25368. private _computeParticleColor;
  25369. private _computeParticleTexture;
  25370. private _computeParticleRotation;
  25371. private _computeParticleVertex;
  25372. private _computeBoundingBox;
  25373. private _depthSortParticles;
  25374. private _camera;
  25375. private _mustUnrotateFixedNormals;
  25376. private _particlesIntersect;
  25377. private _needs32Bits;
  25378. /**
  25379. * Creates a SPS (Solid Particle System) object.
  25380. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25381. * @param scene (Scene) is the scene in which the SPS is added.
  25382. * @param options defines the options of the sps e.g.
  25383. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25384. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25385. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25386. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25387. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25388. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25389. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25390. */
  25391. constructor(name: string, scene: Scene, options?: {
  25392. updatable?: boolean;
  25393. isPickable?: boolean;
  25394. enableDepthSort?: boolean;
  25395. particleIntersection?: boolean;
  25396. boundingSphereOnly?: boolean;
  25397. bSphereRadiusFactor?: number;
  25398. });
  25399. /**
  25400. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25401. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25402. * @returns the created mesh
  25403. */
  25404. buildMesh(): Mesh;
  25405. /**
  25406. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25407. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25408. * Thus the particles generated from `digest()` have their property `position` set yet.
  25409. * @param mesh ( Mesh ) is the mesh to be digested
  25410. * @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
  25411. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25412. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25413. * @returns the current SPS
  25414. */
  25415. digest(mesh: Mesh, options?: {
  25416. facetNb?: number;
  25417. number?: number;
  25418. delta?: number;
  25419. }): SolidParticleSystem;
  25420. private _unrotateFixedNormals;
  25421. private _resetCopy;
  25422. private _meshBuilder;
  25423. private _posToShape;
  25424. private _uvsToShapeUV;
  25425. private _addParticle;
  25426. /**
  25427. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25428. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25429. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25430. * @param nb (positive integer) the number of particles to be created from this model
  25431. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25432. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25433. * @returns the number of shapes in the system
  25434. */
  25435. addShape(mesh: Mesh, nb: number, options?: {
  25436. positionFunction?: any;
  25437. vertexFunction?: any;
  25438. }): number;
  25439. private _rebuildParticle;
  25440. /**
  25441. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25442. * @returns the SPS.
  25443. */
  25444. rebuildMesh(): SolidParticleSystem;
  25445. /**
  25446. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25447. * This method calls `updateParticle()` for each particle of the SPS.
  25448. * For an animated SPS, it is usually called within the render loop.
  25449. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25450. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25451. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25452. * @returns the SPS.
  25453. */
  25454. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25455. /**
  25456. * Disposes the SPS.
  25457. */
  25458. dispose(): void;
  25459. /**
  25460. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25461. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25462. * @returns the SPS.
  25463. */
  25464. refreshVisibleSize(): SolidParticleSystem;
  25465. /**
  25466. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25467. * @param size the size (float) of the visibility box
  25468. * note : this doesn't lock the SPS mesh bounding box.
  25469. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25470. */
  25471. setVisibilityBox(size: number): void;
  25472. /**
  25473. * Gets whether the SPS as always visible or not
  25474. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25475. */
  25476. /**
  25477. * Sets the SPS as always visible or not
  25478. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25479. */
  25480. isAlwaysVisible: boolean;
  25481. /**
  25482. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25483. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25484. */
  25485. /**
  25486. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25487. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25488. */
  25489. isVisibilityBoxLocked: boolean;
  25490. /**
  25491. * Tells to `setParticles()` to compute the particle rotations or not.
  25492. * Default value : true. The SPS is faster when it's set to false.
  25493. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25494. */
  25495. /**
  25496. * Gets if `setParticles()` computes the particle rotations or not.
  25497. * Default value : true. The SPS is faster when it's set to false.
  25498. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25499. */
  25500. computeParticleRotation: boolean;
  25501. /**
  25502. * Tells to `setParticles()` to compute the particle colors or not.
  25503. * Default value : true. The SPS is faster when it's set to false.
  25504. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25505. */
  25506. /**
  25507. * Gets if `setParticles()` computes the particle colors or not.
  25508. * Default value : true. The SPS is faster when it's set to false.
  25509. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25510. */
  25511. computeParticleColor: boolean;
  25512. /**
  25513. * Gets if `setParticles()` computes the particle textures or not.
  25514. * Default value : true. The SPS is faster when it's set to false.
  25515. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25516. */
  25517. computeParticleTexture: boolean;
  25518. /**
  25519. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25520. * Default value : false. The SPS is faster when it's set to false.
  25521. * Note : the particle custom vertex positions aren't stored values.
  25522. */
  25523. /**
  25524. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25525. * Default value : false. The SPS is faster when it's set to false.
  25526. * Note : the particle custom vertex positions aren't stored values.
  25527. */
  25528. computeParticleVertex: boolean;
  25529. /**
  25530. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25531. */
  25532. /**
  25533. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25534. */
  25535. computeBoundingBox: boolean;
  25536. /**
  25537. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25538. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25539. * Default : `true`
  25540. */
  25541. /**
  25542. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25543. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25544. * Default : `true`
  25545. */
  25546. depthSortParticles: boolean;
  25547. /**
  25548. * This function does nothing. It may be overwritten to set all the particle first values.
  25549. * The SPS doesn't call this function, you may have to call it by your own.
  25550. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25551. */
  25552. initParticles(): void;
  25553. /**
  25554. * This function does nothing. It may be overwritten to recycle a particle.
  25555. * The SPS doesn't call this function, you may have to call it by your own.
  25556. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25557. * @param particle The particle to recycle
  25558. * @returns the recycled particle
  25559. */
  25560. recycleParticle(particle: SolidParticle): SolidParticle;
  25561. /**
  25562. * Updates a particle : this function should be overwritten by the user.
  25563. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25564. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25565. * @example : just set a particle position or velocity and recycle conditions
  25566. * @param particle The particle to update
  25567. * @returns the updated particle
  25568. */
  25569. updateParticle(particle: SolidParticle): SolidParticle;
  25570. /**
  25571. * Updates a vertex of a particle : it can be overwritten by the user.
  25572. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25573. * @param particle the current particle
  25574. * @param vertex the current index of the current particle
  25575. * @param pt the index of the current vertex in the particle shape
  25576. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25577. * @example : just set a vertex particle position
  25578. * @returns the updated vertex
  25579. */
  25580. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25581. /**
  25582. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25583. * This does nothing and may be overwritten by the user.
  25584. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25585. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25586. * @param update the boolean update value actually passed to setParticles()
  25587. */
  25588. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25589. /**
  25590. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25591. * This will be passed three parameters.
  25592. * This does nothing and may be overwritten by the user.
  25593. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25594. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25595. * @param update the boolean update value actually passed to setParticles()
  25596. */
  25597. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25598. }
  25599. }
  25600. declare module BABYLON {
  25601. /**
  25602. * Represents one particle of a solid particle system.
  25603. */
  25604. export class SolidParticle {
  25605. /**
  25606. * particle global index
  25607. */
  25608. idx: number;
  25609. /**
  25610. * The color of the particle
  25611. */
  25612. color: Nullable<Color4>;
  25613. /**
  25614. * The world space position of the particle.
  25615. */
  25616. position: Vector3;
  25617. /**
  25618. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25619. */
  25620. rotation: Vector3;
  25621. /**
  25622. * The world space rotation quaternion of the particle.
  25623. */
  25624. rotationQuaternion: Nullable<Quaternion>;
  25625. /**
  25626. * The scaling of the particle.
  25627. */
  25628. scaling: Vector3;
  25629. /**
  25630. * The uvs of the particle.
  25631. */
  25632. uvs: Vector4;
  25633. /**
  25634. * The current speed of the particle.
  25635. */
  25636. velocity: Vector3;
  25637. /**
  25638. * The pivot point in the particle local space.
  25639. */
  25640. pivot: Vector3;
  25641. /**
  25642. * Must the particle be translated from its pivot point in its local space ?
  25643. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25644. * Default : false
  25645. */
  25646. translateFromPivot: boolean;
  25647. /**
  25648. * Is the particle active or not ?
  25649. */
  25650. alive: boolean;
  25651. /**
  25652. * Is the particle visible or not ?
  25653. */
  25654. isVisible: boolean;
  25655. /**
  25656. * Index of this particle in the global "positions" array (Internal use)
  25657. * @hidden
  25658. */
  25659. _pos: number;
  25660. /**
  25661. * @hidden Index of this particle in the global "indices" array (Internal use)
  25662. */
  25663. _ind: number;
  25664. /**
  25665. * @hidden ModelShape of this particle (Internal use)
  25666. */
  25667. _model: ModelShape;
  25668. /**
  25669. * ModelShape id of this particle
  25670. */
  25671. shapeId: number;
  25672. /**
  25673. * Index of the particle in its shape id
  25674. */
  25675. idxInShape: number;
  25676. /**
  25677. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25678. */
  25679. _modelBoundingInfo: BoundingInfo;
  25680. /**
  25681. * @hidden Particle BoundingInfo object (Internal use)
  25682. */
  25683. _boundingInfo: BoundingInfo;
  25684. /**
  25685. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25686. */
  25687. _sps: SolidParticleSystem;
  25688. /**
  25689. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25690. */
  25691. _stillInvisible: boolean;
  25692. /**
  25693. * @hidden Last computed particle rotation matrix
  25694. */
  25695. _rotationMatrix: number[];
  25696. /**
  25697. * Parent particle Id, if any.
  25698. * Default null.
  25699. */
  25700. parentId: Nullable<number>;
  25701. /**
  25702. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25703. * The possible values are :
  25704. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25705. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25706. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25707. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25708. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25709. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25710. * */
  25711. cullingStrategy: number;
  25712. /**
  25713. * @hidden Internal global position in the SPS.
  25714. */
  25715. _globalPosition: Vector3;
  25716. /**
  25717. * Creates a Solid Particle object.
  25718. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25719. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25720. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25721. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25722. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25723. * @param shapeId (integer) is the model shape identifier in the SPS.
  25724. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25725. * @param sps defines the sps it is associated to
  25726. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25727. */
  25728. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25729. /**
  25730. * Legacy support, changed scale to scaling
  25731. */
  25732. /**
  25733. * Legacy support, changed scale to scaling
  25734. */
  25735. scale: Vector3;
  25736. /**
  25737. * Legacy support, changed quaternion to rotationQuaternion
  25738. */
  25739. /**
  25740. * Legacy support, changed quaternion to rotationQuaternion
  25741. */
  25742. quaternion: Nullable<Quaternion>;
  25743. /**
  25744. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25745. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25746. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25747. * @returns true if it intersects
  25748. */
  25749. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25750. /**
  25751. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25752. * A particle is in the frustum if its bounding box intersects the frustum
  25753. * @param frustumPlanes defines the frustum to test
  25754. * @returns true if the particle is in the frustum planes
  25755. */
  25756. isInFrustum(frustumPlanes: Plane[]): boolean;
  25757. /**
  25758. * get the rotation matrix of the particle
  25759. * @hidden
  25760. */
  25761. getRotationMatrix(m: Matrix): void;
  25762. }
  25763. /**
  25764. * Represents the shape of the model used by one particle of a solid particle system.
  25765. * SPS internal tool, don't use it manually.
  25766. */
  25767. export class ModelShape {
  25768. /**
  25769. * The shape id
  25770. * @hidden
  25771. */
  25772. shapeID: number;
  25773. /**
  25774. * flat array of model positions (internal use)
  25775. * @hidden
  25776. */
  25777. _shape: Vector3[];
  25778. /**
  25779. * flat array of model UVs (internal use)
  25780. * @hidden
  25781. */
  25782. _shapeUV: number[];
  25783. /**
  25784. * length of the shape in the model indices array (internal use)
  25785. * @hidden
  25786. */
  25787. _indicesLength: number;
  25788. /**
  25789. * Custom position function (internal use)
  25790. * @hidden
  25791. */
  25792. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25793. /**
  25794. * Custom vertex function (internal use)
  25795. * @hidden
  25796. */
  25797. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25798. /**
  25799. * 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.
  25800. * SPS internal tool, don't use it manually.
  25801. * @hidden
  25802. */
  25803. 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>);
  25804. }
  25805. /**
  25806. * Represents a Depth Sorted Particle in the solid particle system.
  25807. */
  25808. export class DepthSortedParticle {
  25809. /**
  25810. * Index of the particle in the "indices" array
  25811. */
  25812. ind: number;
  25813. /**
  25814. * Length of the particle shape in the "indices" array
  25815. */
  25816. indicesLength: number;
  25817. /**
  25818. * Squared distance from the particle to the camera
  25819. */
  25820. sqDistance: number;
  25821. }
  25822. }
  25823. declare module BABYLON {
  25824. /**
  25825. * @hidden
  25826. */
  25827. export class _MeshCollisionData {
  25828. _checkCollisions: boolean;
  25829. _collisionMask: number;
  25830. _collisionGroup: number;
  25831. _collider: Nullable<Collider>;
  25832. _oldPositionForCollisions: Vector3;
  25833. _diffPositionForCollisions: Vector3;
  25834. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25835. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25836. }
  25837. }
  25838. declare module BABYLON {
  25839. /** @hidden */
  25840. class _FacetDataStorage {
  25841. facetPositions: Vector3[];
  25842. facetNormals: Vector3[];
  25843. facetPartitioning: number[][];
  25844. facetNb: number;
  25845. partitioningSubdivisions: number;
  25846. partitioningBBoxRatio: number;
  25847. facetDataEnabled: boolean;
  25848. facetParameters: any;
  25849. bbSize: Vector3;
  25850. subDiv: {
  25851. max: number;
  25852. X: number;
  25853. Y: number;
  25854. Z: number;
  25855. };
  25856. facetDepthSort: boolean;
  25857. facetDepthSortEnabled: boolean;
  25858. depthSortedIndices: IndicesArray;
  25859. depthSortedFacets: {
  25860. ind: number;
  25861. sqDistance: number;
  25862. }[];
  25863. facetDepthSortFunction: (f1: {
  25864. ind: number;
  25865. sqDistance: number;
  25866. }, f2: {
  25867. ind: number;
  25868. sqDistance: number;
  25869. }) => number;
  25870. facetDepthSortFrom: Vector3;
  25871. facetDepthSortOrigin: Vector3;
  25872. invertedMatrix: Matrix;
  25873. }
  25874. /**
  25875. * @hidden
  25876. **/
  25877. class _InternalAbstractMeshDataInfo {
  25878. _hasVertexAlpha: boolean;
  25879. _useVertexColors: boolean;
  25880. _numBoneInfluencers: number;
  25881. _applyFog: boolean;
  25882. _receiveShadows: boolean;
  25883. _facetData: _FacetDataStorage;
  25884. _visibility: number;
  25885. _skeleton: Nullable<Skeleton>;
  25886. _layerMask: number;
  25887. _computeBonesUsingShaders: boolean;
  25888. _isActive: boolean;
  25889. _onlyForInstances: boolean;
  25890. _isActiveIntermediate: boolean;
  25891. _onlyForInstancesIntermediate: boolean;
  25892. }
  25893. /**
  25894. * Class used to store all common mesh properties
  25895. */
  25896. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25897. /** No occlusion */
  25898. static OCCLUSION_TYPE_NONE: number;
  25899. /** Occlusion set to optimisitic */
  25900. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25901. /** Occlusion set to strict */
  25902. static OCCLUSION_TYPE_STRICT: number;
  25903. /** Use an accurante occlusion algorithm */
  25904. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25905. /** Use a conservative occlusion algorithm */
  25906. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25907. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25908. * Test order :
  25909. * Is the bounding sphere outside the frustum ?
  25910. * If not, are the bounding box vertices outside the frustum ?
  25911. * It not, then the cullable object is in the frustum.
  25912. */
  25913. static readonly CULLINGSTRATEGY_STANDARD: number;
  25914. /** Culling strategy : Bounding Sphere Only.
  25915. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25916. * It's also less accurate than the standard because some not visible objects can still be selected.
  25917. * Test : is the bounding sphere outside the frustum ?
  25918. * If not, then the cullable object is in the frustum.
  25919. */
  25920. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25921. /** Culling strategy : Optimistic Inclusion.
  25922. * This in an inclusion test first, then the standard exclusion test.
  25923. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25924. * 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.
  25925. * Anyway, it's as accurate as the standard strategy.
  25926. * Test :
  25927. * Is the cullable object bounding sphere center in the frustum ?
  25928. * If not, apply the default culling strategy.
  25929. */
  25930. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25931. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25932. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25933. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25934. * 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.
  25935. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25936. * Test :
  25937. * Is the cullable object bounding sphere center in the frustum ?
  25938. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25939. */
  25940. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25941. /**
  25942. * No billboard
  25943. */
  25944. static readonly BILLBOARDMODE_NONE: number;
  25945. /** Billboard on X axis */
  25946. static readonly BILLBOARDMODE_X: number;
  25947. /** Billboard on Y axis */
  25948. static readonly BILLBOARDMODE_Y: number;
  25949. /** Billboard on Z axis */
  25950. static readonly BILLBOARDMODE_Z: number;
  25951. /** Billboard on all axes */
  25952. static readonly BILLBOARDMODE_ALL: number;
  25953. /** Billboard on using position instead of orientation */
  25954. static readonly BILLBOARDMODE_USE_POSITION: number;
  25955. /** @hidden */
  25956. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25957. /**
  25958. * The culling strategy to use to check whether the mesh must be rendered or not.
  25959. * This value can be changed at any time and will be used on the next render mesh selection.
  25960. * The possible values are :
  25961. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25962. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25963. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25964. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25965. * Please read each static variable documentation to get details about the culling process.
  25966. * */
  25967. cullingStrategy: number;
  25968. /**
  25969. * Gets the number of facets in the mesh
  25970. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25971. */
  25972. readonly facetNb: number;
  25973. /**
  25974. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25975. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25976. */
  25977. partitioningSubdivisions: number;
  25978. /**
  25979. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25980. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25981. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25982. */
  25983. partitioningBBoxRatio: number;
  25984. /**
  25985. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25986. * Works only for updatable meshes.
  25987. * Doesn't work with multi-materials
  25988. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25989. */
  25990. mustDepthSortFacets: boolean;
  25991. /**
  25992. * The location (Vector3) where the facet depth sort must be computed from.
  25993. * By default, the active camera position.
  25994. * Used only when facet depth sort is enabled
  25995. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25996. */
  25997. facetDepthSortFrom: Vector3;
  25998. /**
  25999. * gets a boolean indicating if facetData is enabled
  26000. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26001. */
  26002. readonly isFacetDataEnabled: boolean;
  26003. /** @hidden */
  26004. _updateNonUniformScalingState(value: boolean): boolean;
  26005. /**
  26006. * An event triggered when this mesh collides with another one
  26007. */
  26008. onCollideObservable: Observable<AbstractMesh>;
  26009. /** Set a function to call when this mesh collides with another one */
  26010. onCollide: () => void;
  26011. /**
  26012. * An event triggered when the collision's position changes
  26013. */
  26014. onCollisionPositionChangeObservable: Observable<Vector3>;
  26015. /** Set a function to call when the collision's position changes */
  26016. onCollisionPositionChange: () => void;
  26017. /**
  26018. * An event triggered when material is changed
  26019. */
  26020. onMaterialChangedObservable: Observable<AbstractMesh>;
  26021. /**
  26022. * Gets or sets the orientation for POV movement & rotation
  26023. */
  26024. definedFacingForward: boolean;
  26025. /** @hidden */
  26026. _occlusionQuery: Nullable<WebGLQuery>;
  26027. /** @hidden */
  26028. _renderingGroup: Nullable<RenderingGroup>;
  26029. /**
  26030. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26031. */
  26032. /**
  26033. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26034. */
  26035. visibility: number;
  26036. /** Gets or sets the alpha index used to sort transparent meshes
  26037. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26038. */
  26039. alphaIndex: number;
  26040. /**
  26041. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26042. */
  26043. isVisible: boolean;
  26044. /**
  26045. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26046. */
  26047. isPickable: boolean;
  26048. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26049. showSubMeshesBoundingBox: boolean;
  26050. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26051. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26052. */
  26053. isBlocker: boolean;
  26054. /**
  26055. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26056. */
  26057. enablePointerMoveEvents: boolean;
  26058. /**
  26059. * Specifies the rendering group id for this mesh (0 by default)
  26060. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26061. */
  26062. renderingGroupId: number;
  26063. private _material;
  26064. /** Gets or sets current material */
  26065. material: Nullable<Material>;
  26066. /**
  26067. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26068. * @see http://doc.babylonjs.com/babylon101/shadows
  26069. */
  26070. receiveShadows: boolean;
  26071. /** Defines color to use when rendering outline */
  26072. outlineColor: Color3;
  26073. /** Define width to use when rendering outline */
  26074. outlineWidth: number;
  26075. /** Defines color to use when rendering overlay */
  26076. overlayColor: Color3;
  26077. /** Defines alpha to use when rendering overlay */
  26078. overlayAlpha: number;
  26079. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26080. hasVertexAlpha: boolean;
  26081. /** 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) */
  26082. useVertexColors: boolean;
  26083. /**
  26084. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26085. */
  26086. computeBonesUsingShaders: boolean;
  26087. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26088. numBoneInfluencers: number;
  26089. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26090. applyFog: boolean;
  26091. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26092. useOctreeForRenderingSelection: boolean;
  26093. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26094. useOctreeForPicking: boolean;
  26095. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26096. useOctreeForCollisions: boolean;
  26097. /**
  26098. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26099. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26100. */
  26101. layerMask: number;
  26102. /**
  26103. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26104. */
  26105. alwaysSelectAsActiveMesh: boolean;
  26106. /**
  26107. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26108. */
  26109. doNotSyncBoundingInfo: boolean;
  26110. /**
  26111. * Gets or sets the current action manager
  26112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26113. */
  26114. actionManager: Nullable<AbstractActionManager>;
  26115. private _meshCollisionData;
  26116. /**
  26117. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26118. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26119. */
  26120. ellipsoid: Vector3;
  26121. /**
  26122. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26123. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26124. */
  26125. ellipsoidOffset: Vector3;
  26126. /**
  26127. * Gets or sets a collision mask used to mask collisions (default is -1).
  26128. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26129. */
  26130. collisionMask: number;
  26131. /**
  26132. * Gets or sets the current collision group mask (-1 by default).
  26133. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26134. */
  26135. collisionGroup: number;
  26136. /**
  26137. * Defines edge width used when edgesRenderer is enabled
  26138. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26139. */
  26140. edgesWidth: number;
  26141. /**
  26142. * Defines edge color used when edgesRenderer is enabled
  26143. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26144. */
  26145. edgesColor: Color4;
  26146. /** @hidden */
  26147. _edgesRenderer: Nullable<IEdgesRenderer>;
  26148. /** @hidden */
  26149. _masterMesh: Nullable<AbstractMesh>;
  26150. /** @hidden */
  26151. _boundingInfo: Nullable<BoundingInfo>;
  26152. /** @hidden */
  26153. _renderId: number;
  26154. /**
  26155. * Gets or sets the list of subMeshes
  26156. * @see http://doc.babylonjs.com/how_to/multi_materials
  26157. */
  26158. subMeshes: SubMesh[];
  26159. /** @hidden */
  26160. _intersectionsInProgress: AbstractMesh[];
  26161. /** @hidden */
  26162. _unIndexed: boolean;
  26163. /** @hidden */
  26164. _lightSources: Light[];
  26165. /** Gets the list of lights affecting that mesh */
  26166. readonly lightSources: Light[];
  26167. /** @hidden */
  26168. readonly _positions: Nullable<Vector3[]>;
  26169. /** @hidden */
  26170. _waitingData: {
  26171. lods: Nullable<any>;
  26172. actions: Nullable<any>;
  26173. freezeWorldMatrix: Nullable<boolean>;
  26174. };
  26175. /** @hidden */
  26176. _bonesTransformMatrices: Nullable<Float32Array>;
  26177. /** @hidden */
  26178. _transformMatrixTexture: Nullable<RawTexture>;
  26179. /**
  26180. * Gets or sets a skeleton to apply skining transformations
  26181. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26182. */
  26183. skeleton: Nullable<Skeleton>;
  26184. /**
  26185. * An event triggered when the mesh is rebuilt.
  26186. */
  26187. onRebuildObservable: Observable<AbstractMesh>;
  26188. /**
  26189. * Creates a new AbstractMesh
  26190. * @param name defines the name of the mesh
  26191. * @param scene defines the hosting scene
  26192. */
  26193. constructor(name: string, scene?: Nullable<Scene>);
  26194. /**
  26195. * Returns the string "AbstractMesh"
  26196. * @returns "AbstractMesh"
  26197. */
  26198. getClassName(): string;
  26199. /**
  26200. * Gets a string representation of the current mesh
  26201. * @param fullDetails defines a boolean indicating if full details must be included
  26202. * @returns a string representation of the current mesh
  26203. */
  26204. toString(fullDetails?: boolean): string;
  26205. /**
  26206. * @hidden
  26207. */
  26208. protected _getEffectiveParent(): Nullable<Node>;
  26209. /** @hidden */
  26210. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26211. /** @hidden */
  26212. _rebuild(): void;
  26213. /** @hidden */
  26214. _resyncLightSources(): void;
  26215. /** @hidden */
  26216. _resyncLighSource(light: Light): void;
  26217. /** @hidden */
  26218. _unBindEffect(): void;
  26219. /** @hidden */
  26220. _removeLightSource(light: Light, dispose: boolean): void;
  26221. private _markSubMeshesAsDirty;
  26222. /** @hidden */
  26223. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26224. /** @hidden */
  26225. _markSubMeshesAsAttributesDirty(): void;
  26226. /** @hidden */
  26227. _markSubMeshesAsMiscDirty(): void;
  26228. /**
  26229. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26230. */
  26231. scaling: Vector3;
  26232. /**
  26233. * Returns true if the mesh is blocked. Implemented by child classes
  26234. */
  26235. readonly isBlocked: boolean;
  26236. /**
  26237. * Returns the mesh itself by default. Implemented by child classes
  26238. * @param camera defines the camera to use to pick the right LOD level
  26239. * @returns the currentAbstractMesh
  26240. */
  26241. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26242. /**
  26243. * Returns 0 by default. Implemented by child classes
  26244. * @returns an integer
  26245. */
  26246. getTotalVertices(): number;
  26247. /**
  26248. * Returns a positive integer : the total number of indices in this mesh geometry.
  26249. * @returns the numner of indices or zero if the mesh has no geometry.
  26250. */
  26251. getTotalIndices(): number;
  26252. /**
  26253. * Returns null by default. Implemented by child classes
  26254. * @returns null
  26255. */
  26256. getIndices(): Nullable<IndicesArray>;
  26257. /**
  26258. * Returns the array of the requested vertex data kind. Implemented by child classes
  26259. * @param kind defines the vertex data kind to use
  26260. * @returns null
  26261. */
  26262. getVerticesData(kind: string): Nullable<FloatArray>;
  26263. /**
  26264. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26265. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26266. * Note that a new underlying VertexBuffer object is created each call.
  26267. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26268. * @param kind defines vertex data kind:
  26269. * * VertexBuffer.PositionKind
  26270. * * VertexBuffer.UVKind
  26271. * * VertexBuffer.UV2Kind
  26272. * * VertexBuffer.UV3Kind
  26273. * * VertexBuffer.UV4Kind
  26274. * * VertexBuffer.UV5Kind
  26275. * * VertexBuffer.UV6Kind
  26276. * * VertexBuffer.ColorKind
  26277. * * VertexBuffer.MatricesIndicesKind
  26278. * * VertexBuffer.MatricesIndicesExtraKind
  26279. * * VertexBuffer.MatricesWeightsKind
  26280. * * VertexBuffer.MatricesWeightsExtraKind
  26281. * @param data defines the data source
  26282. * @param updatable defines if the data must be flagged as updatable (or static)
  26283. * @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
  26284. * @returns the current mesh
  26285. */
  26286. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26287. /**
  26288. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26289. * If the mesh has no geometry, it is simply returned as it is.
  26290. * @param kind defines vertex data kind:
  26291. * * VertexBuffer.PositionKind
  26292. * * VertexBuffer.UVKind
  26293. * * VertexBuffer.UV2Kind
  26294. * * VertexBuffer.UV3Kind
  26295. * * VertexBuffer.UV4Kind
  26296. * * VertexBuffer.UV5Kind
  26297. * * VertexBuffer.UV6Kind
  26298. * * VertexBuffer.ColorKind
  26299. * * VertexBuffer.MatricesIndicesKind
  26300. * * VertexBuffer.MatricesIndicesExtraKind
  26301. * * VertexBuffer.MatricesWeightsKind
  26302. * * VertexBuffer.MatricesWeightsExtraKind
  26303. * @param data defines the data source
  26304. * @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
  26305. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26306. * @returns the current mesh
  26307. */
  26308. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26309. /**
  26310. * Sets the mesh indices,
  26311. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26312. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26313. * @param totalVertices Defines the total number of vertices
  26314. * @returns the current mesh
  26315. */
  26316. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26317. /**
  26318. * Gets a boolean indicating if specific vertex data is present
  26319. * @param kind defines the vertex data kind to use
  26320. * @returns true is data kind is present
  26321. */
  26322. isVerticesDataPresent(kind: string): boolean;
  26323. /**
  26324. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26325. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26326. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26327. * @returns a BoundingInfo
  26328. */
  26329. getBoundingInfo(): BoundingInfo;
  26330. /**
  26331. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26332. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26333. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26334. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26335. * @returns the current mesh
  26336. */
  26337. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26338. /**
  26339. * Overwrite the current bounding info
  26340. * @param boundingInfo defines the new bounding info
  26341. * @returns the current mesh
  26342. */
  26343. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26344. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26345. readonly useBones: boolean;
  26346. /** @hidden */
  26347. _preActivate(): void;
  26348. /** @hidden */
  26349. _preActivateForIntermediateRendering(renderId: number): void;
  26350. /** @hidden */
  26351. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26352. /** @hidden */
  26353. _postActivate(): void;
  26354. /** @hidden */
  26355. _freeze(): void;
  26356. /** @hidden */
  26357. _unFreeze(): void;
  26358. /**
  26359. * Gets the current world matrix
  26360. * @returns a Matrix
  26361. */
  26362. getWorldMatrix(): Matrix;
  26363. /** @hidden */
  26364. _getWorldMatrixDeterminant(): number;
  26365. /**
  26366. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26367. */
  26368. readonly isAnInstance: boolean;
  26369. /**
  26370. * Gets a boolean indicating if this mesh has instances
  26371. */
  26372. readonly hasInstances: boolean;
  26373. /**
  26374. * Perform relative position change from the point of view of behind the front of the mesh.
  26375. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26376. * Supports definition of mesh facing forward or backward
  26377. * @param amountRight defines the distance on the right axis
  26378. * @param amountUp defines the distance on the up axis
  26379. * @param amountForward defines the distance on the forward axis
  26380. * @returns the current mesh
  26381. */
  26382. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26383. /**
  26384. * Calculate relative position change from the point of view of behind the front of the mesh.
  26385. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26386. * Supports definition of mesh facing forward or backward
  26387. * @param amountRight defines the distance on the right axis
  26388. * @param amountUp defines the distance on the up axis
  26389. * @param amountForward defines the distance on the forward axis
  26390. * @returns the new displacement vector
  26391. */
  26392. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26393. /**
  26394. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26395. * Supports definition of mesh facing forward or backward
  26396. * @param flipBack defines the flip
  26397. * @param twirlClockwise defines the twirl
  26398. * @param tiltRight defines the tilt
  26399. * @returns the current mesh
  26400. */
  26401. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26402. /**
  26403. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26404. * Supports definition of mesh facing forward or backward.
  26405. * @param flipBack defines the flip
  26406. * @param twirlClockwise defines the twirl
  26407. * @param tiltRight defines the tilt
  26408. * @returns the new rotation vector
  26409. */
  26410. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26411. /**
  26412. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26413. * This means the mesh underlying bounding box and sphere are recomputed.
  26414. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26415. * @returns the current mesh
  26416. */
  26417. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26418. /** @hidden */
  26419. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26420. /** @hidden */
  26421. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26422. /** @hidden */
  26423. _updateBoundingInfo(): AbstractMesh;
  26424. /** @hidden */
  26425. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26426. /** @hidden */
  26427. protected _afterComputeWorldMatrix(): void;
  26428. /** @hidden */
  26429. readonly _effectiveMesh: AbstractMesh;
  26430. /**
  26431. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26432. * A mesh is in the frustum if its bounding box intersects the frustum
  26433. * @param frustumPlanes defines the frustum to test
  26434. * @returns true if the mesh is in the frustum planes
  26435. */
  26436. isInFrustum(frustumPlanes: Plane[]): boolean;
  26437. /**
  26438. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26439. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26440. * @param frustumPlanes defines the frustum to test
  26441. * @returns true if the mesh is completely in the frustum planes
  26442. */
  26443. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26444. /**
  26445. * True if the mesh intersects another mesh or a SolidParticle object
  26446. * @param mesh defines a target mesh or SolidParticle to test
  26447. * @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)
  26448. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26449. * @returns true if there is an intersection
  26450. */
  26451. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26452. /**
  26453. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26454. * @param point defines the point to test
  26455. * @returns true if there is an intersection
  26456. */
  26457. intersectsPoint(point: Vector3): boolean;
  26458. /**
  26459. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26460. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26461. */
  26462. checkCollisions: boolean;
  26463. /**
  26464. * Gets Collider object used to compute collisions (not physics)
  26465. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26466. */
  26467. readonly collider: Nullable<Collider>;
  26468. /**
  26469. * Move the mesh using collision engine
  26470. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26471. * @param displacement defines the requested displacement vector
  26472. * @returns the current mesh
  26473. */
  26474. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26475. private _onCollisionPositionChange;
  26476. /** @hidden */
  26477. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26478. /** @hidden */
  26479. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26480. /** @hidden */
  26481. _checkCollision(collider: Collider): AbstractMesh;
  26482. /** @hidden */
  26483. _generatePointsArray(): boolean;
  26484. /**
  26485. * Checks if the passed Ray intersects with the mesh
  26486. * @param ray defines the ray to use
  26487. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26488. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26489. * @returns the picking info
  26490. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26491. */
  26492. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26493. /**
  26494. * Clones the current mesh
  26495. * @param name defines the mesh name
  26496. * @param newParent defines the new mesh parent
  26497. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26498. * @returns the new mesh
  26499. */
  26500. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26501. /**
  26502. * Disposes all the submeshes of the current meshnp
  26503. * @returns the current mesh
  26504. */
  26505. releaseSubMeshes(): AbstractMesh;
  26506. /**
  26507. * Releases resources associated with this abstract mesh.
  26508. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26509. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26510. */
  26511. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26512. /**
  26513. * Adds the passed mesh as a child to the current mesh
  26514. * @param mesh defines the child mesh
  26515. * @returns the current mesh
  26516. */
  26517. addChild(mesh: AbstractMesh): AbstractMesh;
  26518. /**
  26519. * Removes the passed mesh from the current mesh children list
  26520. * @param mesh defines the child mesh
  26521. * @returns the current mesh
  26522. */
  26523. removeChild(mesh: AbstractMesh): AbstractMesh;
  26524. /** @hidden */
  26525. private _initFacetData;
  26526. /**
  26527. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26528. * This method can be called within the render loop.
  26529. * 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
  26530. * @returns the current mesh
  26531. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26532. */
  26533. updateFacetData(): AbstractMesh;
  26534. /**
  26535. * Returns the facetLocalNormals array.
  26536. * The normals are expressed in the mesh local spac
  26537. * @returns an array of Vector3
  26538. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26539. */
  26540. getFacetLocalNormals(): Vector3[];
  26541. /**
  26542. * Returns the facetLocalPositions array.
  26543. * The facet positions are expressed in the mesh local space
  26544. * @returns an array of Vector3
  26545. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26546. */
  26547. getFacetLocalPositions(): Vector3[];
  26548. /**
  26549. * Returns the facetLocalPartioning array
  26550. * @returns an array of array of numbers
  26551. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26552. */
  26553. getFacetLocalPartitioning(): number[][];
  26554. /**
  26555. * Returns the i-th facet position in the world system.
  26556. * This method allocates a new Vector3 per call
  26557. * @param i defines the facet index
  26558. * @returns a new Vector3
  26559. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26560. */
  26561. getFacetPosition(i: number): Vector3;
  26562. /**
  26563. * Sets the reference Vector3 with the i-th facet position in the world system
  26564. * @param i defines the facet index
  26565. * @param ref defines the target vector
  26566. * @returns the current mesh
  26567. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26568. */
  26569. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26570. /**
  26571. * Returns the i-th facet normal in the world system.
  26572. * This method allocates a new Vector3 per call
  26573. * @param i defines the facet index
  26574. * @returns a new Vector3
  26575. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26576. */
  26577. getFacetNormal(i: number): Vector3;
  26578. /**
  26579. * Sets the reference Vector3 with the i-th facet normal in the world system
  26580. * @param i defines the facet index
  26581. * @param ref defines the target vector
  26582. * @returns the current mesh
  26583. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26584. */
  26585. getFacetNormalToRef(i: number, ref: Vector3): this;
  26586. /**
  26587. * 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)
  26588. * @param x defines x coordinate
  26589. * @param y defines y coordinate
  26590. * @param z defines z coordinate
  26591. * @returns the array of facet indexes
  26592. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26593. */
  26594. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26595. /**
  26596. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26597. * @param projected sets as the (x,y,z) world projection on the facet
  26598. * @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
  26599. * @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
  26600. * @param x defines x coordinate
  26601. * @param y defines y coordinate
  26602. * @param z defines z coordinate
  26603. * @returns the face index if found (or null instead)
  26604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26605. */
  26606. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26607. /**
  26608. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26609. * @param projected sets as the (x,y,z) local projection on the facet
  26610. * @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
  26611. * @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
  26612. * @param x defines x coordinate
  26613. * @param y defines y coordinate
  26614. * @param z defines z coordinate
  26615. * @returns the face index if found (or null instead)
  26616. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26617. */
  26618. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26619. /**
  26620. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26621. * @returns the parameters
  26622. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26623. */
  26624. getFacetDataParameters(): any;
  26625. /**
  26626. * Disables the feature FacetData and frees the related memory
  26627. * @returns the current mesh
  26628. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26629. */
  26630. disableFacetData(): AbstractMesh;
  26631. /**
  26632. * Updates the AbstractMesh indices array
  26633. * @param indices defines the data source
  26634. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26635. * @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)
  26636. * @returns the current mesh
  26637. */
  26638. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26639. /**
  26640. * Creates new normals data for the mesh
  26641. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26642. * @returns the current mesh
  26643. */
  26644. createNormals(updatable: boolean): AbstractMesh;
  26645. /**
  26646. * Align the mesh with a normal
  26647. * @param normal defines the normal to use
  26648. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26649. * @returns the current mesh
  26650. */
  26651. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26652. /** @hidden */
  26653. _checkOcclusionQuery(): boolean;
  26654. /**
  26655. * Disables the mesh edge rendering mode
  26656. * @returns the currentAbstractMesh
  26657. */
  26658. disableEdgesRendering(): AbstractMesh;
  26659. /**
  26660. * Enables the edge rendering mode on the mesh.
  26661. * This mode makes the mesh edges visible
  26662. * @param epsilon defines the maximal distance between two angles to detect a face
  26663. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26664. * @returns the currentAbstractMesh
  26665. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26666. */
  26667. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26668. }
  26669. }
  26670. declare module BABYLON {
  26671. /**
  26672. * Interface used to define ActionEvent
  26673. */
  26674. export interface IActionEvent {
  26675. /** The mesh or sprite that triggered the action */
  26676. source: any;
  26677. /** The X mouse cursor position at the time of the event */
  26678. pointerX: number;
  26679. /** The Y mouse cursor position at the time of the event */
  26680. pointerY: number;
  26681. /** The mesh that is currently pointed at (can be null) */
  26682. meshUnderPointer: Nullable<AbstractMesh>;
  26683. /** the original (browser) event that triggered the ActionEvent */
  26684. sourceEvent?: any;
  26685. /** additional data for the event */
  26686. additionalData?: any;
  26687. }
  26688. /**
  26689. * ActionEvent is the event being sent when an action is triggered.
  26690. */
  26691. export class ActionEvent implements IActionEvent {
  26692. /** The mesh or sprite that triggered the action */
  26693. source: any;
  26694. /** The X mouse cursor position at the time of the event */
  26695. pointerX: number;
  26696. /** The Y mouse cursor position at the time of the event */
  26697. pointerY: number;
  26698. /** The mesh that is currently pointed at (can be null) */
  26699. meshUnderPointer: Nullable<AbstractMesh>;
  26700. /** the original (browser) event that triggered the ActionEvent */
  26701. sourceEvent?: any;
  26702. /** additional data for the event */
  26703. additionalData?: any;
  26704. /**
  26705. * Creates a new ActionEvent
  26706. * @param source The mesh or sprite that triggered the action
  26707. * @param pointerX The X mouse cursor position at the time of the event
  26708. * @param pointerY The Y mouse cursor position at the time of the event
  26709. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26710. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26711. * @param additionalData additional data for the event
  26712. */
  26713. constructor(
  26714. /** The mesh or sprite that triggered the action */
  26715. source: any,
  26716. /** The X mouse cursor position at the time of the event */
  26717. pointerX: number,
  26718. /** The Y mouse cursor position at the time of the event */
  26719. pointerY: number,
  26720. /** The mesh that is currently pointed at (can be null) */
  26721. meshUnderPointer: Nullable<AbstractMesh>,
  26722. /** the original (browser) event that triggered the ActionEvent */
  26723. sourceEvent?: any,
  26724. /** additional data for the event */
  26725. additionalData?: any);
  26726. /**
  26727. * Helper function to auto-create an ActionEvent from a source mesh.
  26728. * @param source The source mesh that triggered the event
  26729. * @param evt The original (browser) event
  26730. * @param additionalData additional data for the event
  26731. * @returns the new ActionEvent
  26732. */
  26733. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26734. /**
  26735. * Helper function to auto-create an ActionEvent from a source sprite
  26736. * @param source The source sprite that triggered the event
  26737. * @param scene Scene associated with the sprite
  26738. * @param evt The original (browser) event
  26739. * @param additionalData additional data for the event
  26740. * @returns the new ActionEvent
  26741. */
  26742. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26743. /**
  26744. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26745. * @param scene the scene where the event occurred
  26746. * @param evt The original (browser) event
  26747. * @returns the new ActionEvent
  26748. */
  26749. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26750. /**
  26751. * Helper function to auto-create an ActionEvent from a primitive
  26752. * @param prim defines the target primitive
  26753. * @param pointerPos defines the pointer position
  26754. * @param evt The original (browser) event
  26755. * @param additionalData additional data for the event
  26756. * @returns the new ActionEvent
  26757. */
  26758. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26759. }
  26760. }
  26761. declare module BABYLON {
  26762. /**
  26763. * Abstract class used to decouple action Manager from scene and meshes.
  26764. * Do not instantiate.
  26765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26766. */
  26767. export abstract class AbstractActionManager implements IDisposable {
  26768. /** Gets the list of active triggers */
  26769. static Triggers: {
  26770. [key: string]: number;
  26771. };
  26772. /** Gets the cursor to use when hovering items */
  26773. hoverCursor: string;
  26774. /** Gets the list of actions */
  26775. actions: IAction[];
  26776. /**
  26777. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26778. */
  26779. isRecursive: boolean;
  26780. /**
  26781. * Releases all associated resources
  26782. */
  26783. abstract dispose(): void;
  26784. /**
  26785. * Does this action manager has pointer triggers
  26786. */
  26787. abstract readonly hasPointerTriggers: boolean;
  26788. /**
  26789. * Does this action manager has pick triggers
  26790. */
  26791. abstract readonly hasPickTriggers: boolean;
  26792. /**
  26793. * Process a specific trigger
  26794. * @param trigger defines the trigger to process
  26795. * @param evt defines the event details to be processed
  26796. */
  26797. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26798. /**
  26799. * Does this action manager handles actions of any of the given triggers
  26800. * @param triggers defines the triggers to be tested
  26801. * @return a boolean indicating whether one (or more) of the triggers is handled
  26802. */
  26803. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26804. /**
  26805. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26806. * speed.
  26807. * @param triggerA defines the trigger to be tested
  26808. * @param triggerB defines the trigger to be tested
  26809. * @return a boolean indicating whether one (or more) of the triggers is handled
  26810. */
  26811. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26812. /**
  26813. * Does this action manager handles actions of a given trigger
  26814. * @param trigger defines the trigger to be tested
  26815. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26816. * @return whether the trigger is handled
  26817. */
  26818. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26819. /**
  26820. * Serialize this manager to a JSON object
  26821. * @param name defines the property name to store this manager
  26822. * @returns a JSON representation of this manager
  26823. */
  26824. abstract serialize(name: string): any;
  26825. /**
  26826. * Registers an action to this action manager
  26827. * @param action defines the action to be registered
  26828. * @return the action amended (prepared) after registration
  26829. */
  26830. abstract registerAction(action: IAction): Nullable<IAction>;
  26831. /**
  26832. * Unregisters an action to this action manager
  26833. * @param action defines the action to be unregistered
  26834. * @return a boolean indicating whether the action has been unregistered
  26835. */
  26836. abstract unregisterAction(action: IAction): Boolean;
  26837. /**
  26838. * Does exist one action manager with at least one trigger
  26839. **/
  26840. static readonly HasTriggers: boolean;
  26841. /**
  26842. * Does exist one action manager with at least one pick trigger
  26843. **/
  26844. static readonly HasPickTriggers: boolean;
  26845. /**
  26846. * Does exist one action manager that handles actions of a given trigger
  26847. * @param trigger defines the trigger to be tested
  26848. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26849. **/
  26850. static HasSpecificTrigger(trigger: number): boolean;
  26851. }
  26852. }
  26853. declare module BABYLON {
  26854. /**
  26855. * Defines how a node can be built from a string name.
  26856. */
  26857. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26858. /**
  26859. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26860. */
  26861. export class Node implements IBehaviorAware<Node> {
  26862. /** @hidden */
  26863. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26864. private static _NodeConstructors;
  26865. /**
  26866. * Add a new node constructor
  26867. * @param type defines the type name of the node to construct
  26868. * @param constructorFunc defines the constructor function
  26869. */
  26870. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26871. /**
  26872. * Returns a node constructor based on type name
  26873. * @param type defines the type name
  26874. * @param name defines the new node name
  26875. * @param scene defines the hosting scene
  26876. * @param options defines optional options to transmit to constructors
  26877. * @returns the new constructor or null
  26878. */
  26879. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26880. /**
  26881. * Gets or sets the name of the node
  26882. */
  26883. name: string;
  26884. /**
  26885. * Gets or sets the id of the node
  26886. */
  26887. id: string;
  26888. /**
  26889. * Gets or sets the unique id of the node
  26890. */
  26891. uniqueId: number;
  26892. /**
  26893. * Gets or sets a string used to store user defined state for the node
  26894. */
  26895. state: string;
  26896. /**
  26897. * Gets or sets an object used to store user defined information for the node
  26898. */
  26899. metadata: any;
  26900. /**
  26901. * For internal use only. Please do not use.
  26902. */
  26903. reservedDataStore: any;
  26904. /**
  26905. * List of inspectable custom properties (used by the Inspector)
  26906. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26907. */
  26908. inspectableCustomProperties: IInspectable[];
  26909. private _doNotSerialize;
  26910. /**
  26911. * Gets or sets a boolean used to define if the node must be serialized
  26912. */
  26913. doNotSerialize: boolean;
  26914. /** @hidden */
  26915. _isDisposed: boolean;
  26916. /**
  26917. * Gets a list of Animations associated with the node
  26918. */
  26919. animations: Animation[];
  26920. protected _ranges: {
  26921. [name: string]: Nullable<AnimationRange>;
  26922. };
  26923. /**
  26924. * Callback raised when the node is ready to be used
  26925. */
  26926. onReady: Nullable<(node: Node) => void>;
  26927. private _isEnabled;
  26928. private _isParentEnabled;
  26929. private _isReady;
  26930. /** @hidden */
  26931. _currentRenderId: number;
  26932. private _parentUpdateId;
  26933. /** @hidden */
  26934. _childUpdateId: number;
  26935. /** @hidden */
  26936. _waitingParentId: Nullable<string>;
  26937. /** @hidden */
  26938. _scene: Scene;
  26939. /** @hidden */
  26940. _cache: any;
  26941. private _parentNode;
  26942. private _children;
  26943. /** @hidden */
  26944. _worldMatrix: Matrix;
  26945. /** @hidden */
  26946. _worldMatrixDeterminant: number;
  26947. /** @hidden */
  26948. _worldMatrixDeterminantIsDirty: boolean;
  26949. /** @hidden */
  26950. private _sceneRootNodesIndex;
  26951. /**
  26952. * Gets a boolean indicating if the node has been disposed
  26953. * @returns true if the node was disposed
  26954. */
  26955. isDisposed(): boolean;
  26956. /**
  26957. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26958. * @see https://doc.babylonjs.com/how_to/parenting
  26959. */
  26960. parent: Nullable<Node>;
  26961. private addToSceneRootNodes;
  26962. private removeFromSceneRootNodes;
  26963. private _animationPropertiesOverride;
  26964. /**
  26965. * Gets or sets the animation properties override
  26966. */
  26967. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26968. /**
  26969. * Gets a string idenfifying the name of the class
  26970. * @returns "Node" string
  26971. */
  26972. getClassName(): string;
  26973. /** @hidden */
  26974. readonly _isNode: boolean;
  26975. /**
  26976. * An event triggered when the mesh is disposed
  26977. */
  26978. onDisposeObservable: Observable<Node>;
  26979. private _onDisposeObserver;
  26980. /**
  26981. * Sets a callback that will be raised when the node will be disposed
  26982. */
  26983. onDispose: () => void;
  26984. /**
  26985. * Creates a new Node
  26986. * @param name the name and id to be given to this node
  26987. * @param scene the scene this node will be added to
  26988. * @param addToRootNodes the node will be added to scene.rootNodes
  26989. */
  26990. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26991. /**
  26992. * Gets the scene of the node
  26993. * @returns a scene
  26994. */
  26995. getScene(): Scene;
  26996. /**
  26997. * Gets the engine of the node
  26998. * @returns a Engine
  26999. */
  27000. getEngine(): Engine;
  27001. private _behaviors;
  27002. /**
  27003. * Attach a behavior to the node
  27004. * @see http://doc.babylonjs.com/features/behaviour
  27005. * @param behavior defines the behavior to attach
  27006. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27007. * @returns the current Node
  27008. */
  27009. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27010. /**
  27011. * Remove an attached behavior
  27012. * @see http://doc.babylonjs.com/features/behaviour
  27013. * @param behavior defines the behavior to attach
  27014. * @returns the current Node
  27015. */
  27016. removeBehavior(behavior: Behavior<Node>): Node;
  27017. /**
  27018. * Gets the list of attached behaviors
  27019. * @see http://doc.babylonjs.com/features/behaviour
  27020. */
  27021. readonly behaviors: Behavior<Node>[];
  27022. /**
  27023. * Gets an attached behavior by name
  27024. * @param name defines the name of the behavior to look for
  27025. * @see http://doc.babylonjs.com/features/behaviour
  27026. * @returns null if behavior was not found else the requested behavior
  27027. */
  27028. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27029. /**
  27030. * Returns the latest update of the World matrix
  27031. * @returns a Matrix
  27032. */
  27033. getWorldMatrix(): Matrix;
  27034. /** @hidden */
  27035. _getWorldMatrixDeterminant(): number;
  27036. /**
  27037. * Returns directly the latest state of the mesh World matrix.
  27038. * A Matrix is returned.
  27039. */
  27040. readonly worldMatrixFromCache: Matrix;
  27041. /** @hidden */
  27042. _initCache(): void;
  27043. /** @hidden */
  27044. updateCache(force?: boolean): void;
  27045. /** @hidden */
  27046. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27047. /** @hidden */
  27048. _updateCache(ignoreParentClass?: boolean): void;
  27049. /** @hidden */
  27050. _isSynchronized(): boolean;
  27051. /** @hidden */
  27052. _markSyncedWithParent(): void;
  27053. /** @hidden */
  27054. isSynchronizedWithParent(): boolean;
  27055. /** @hidden */
  27056. isSynchronized(): boolean;
  27057. /**
  27058. * Is this node ready to be used/rendered
  27059. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27060. * @return true if the node is ready
  27061. */
  27062. isReady(completeCheck?: boolean): boolean;
  27063. /**
  27064. * Is this node enabled?
  27065. * 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
  27066. * @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
  27067. * @return whether this node (and its parent) is enabled
  27068. */
  27069. isEnabled(checkAncestors?: boolean): boolean;
  27070. /** @hidden */
  27071. protected _syncParentEnabledState(): void;
  27072. /**
  27073. * Set the enabled state of this node
  27074. * @param value defines the new enabled state
  27075. */
  27076. setEnabled(value: boolean): void;
  27077. /**
  27078. * Is this node a descendant of the given node?
  27079. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27080. * @param ancestor defines the parent node to inspect
  27081. * @returns a boolean indicating if this node is a descendant of the given node
  27082. */
  27083. isDescendantOf(ancestor: Node): boolean;
  27084. /** @hidden */
  27085. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27086. /**
  27087. * Will return all nodes that have this node as ascendant
  27088. * @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
  27089. * @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
  27090. * @return all children nodes of all types
  27091. */
  27092. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27093. /**
  27094. * Get all child-meshes of this node
  27095. * @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)
  27096. * @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
  27097. * @returns an array of AbstractMesh
  27098. */
  27099. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27100. /**
  27101. * Get all direct children of this node
  27102. * @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
  27103. * @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)
  27104. * @returns an array of Node
  27105. */
  27106. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27107. /** @hidden */
  27108. _setReady(state: boolean): void;
  27109. /**
  27110. * Get an animation by name
  27111. * @param name defines the name of the animation to look for
  27112. * @returns null if not found else the requested animation
  27113. */
  27114. getAnimationByName(name: string): Nullable<Animation>;
  27115. /**
  27116. * Creates an animation range for this node
  27117. * @param name defines the name of the range
  27118. * @param from defines the starting key
  27119. * @param to defines the end key
  27120. */
  27121. createAnimationRange(name: string, from: number, to: number): void;
  27122. /**
  27123. * Delete a specific animation range
  27124. * @param name defines the name of the range to delete
  27125. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27126. */
  27127. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27128. /**
  27129. * Get an animation range by name
  27130. * @param name defines the name of the animation range to look for
  27131. * @returns null if not found else the requested animation range
  27132. */
  27133. getAnimationRange(name: string): Nullable<AnimationRange>;
  27134. /**
  27135. * Gets the list of all animation ranges defined on this node
  27136. * @returns an array
  27137. */
  27138. getAnimationRanges(): Nullable<AnimationRange>[];
  27139. /**
  27140. * Will start the animation sequence
  27141. * @param name defines the range frames for animation sequence
  27142. * @param loop defines if the animation should loop (false by default)
  27143. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27144. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27145. * @returns the object created for this animation. If range does not exist, it will return null
  27146. */
  27147. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27148. /**
  27149. * Serialize animation ranges into a JSON compatible object
  27150. * @returns serialization object
  27151. */
  27152. serializeAnimationRanges(): any;
  27153. /**
  27154. * Computes the world matrix of the node
  27155. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27156. * @returns the world matrix
  27157. */
  27158. computeWorldMatrix(force?: boolean): Matrix;
  27159. /**
  27160. * Releases resources associated with this node.
  27161. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27162. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27163. */
  27164. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27165. /**
  27166. * Parse animation range data from a serialization object and store them into a given node
  27167. * @param node defines where to store the animation ranges
  27168. * @param parsedNode defines the serialization object to read data from
  27169. * @param scene defines the hosting scene
  27170. */
  27171. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27172. /**
  27173. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27174. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27175. * @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
  27176. * @returns the new bounding vectors
  27177. */
  27178. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27179. min: Vector3;
  27180. max: Vector3;
  27181. };
  27182. }
  27183. }
  27184. declare module BABYLON {
  27185. /**
  27186. * @hidden
  27187. */
  27188. export class _IAnimationState {
  27189. key: number;
  27190. repeatCount: number;
  27191. workValue?: any;
  27192. loopMode?: number;
  27193. offsetValue?: any;
  27194. highLimitValue?: any;
  27195. }
  27196. /**
  27197. * Class used to store any kind of animation
  27198. */
  27199. export class Animation {
  27200. /**Name of the animation */
  27201. name: string;
  27202. /**Property to animate */
  27203. targetProperty: string;
  27204. /**The frames per second of the animation */
  27205. framePerSecond: number;
  27206. /**The data type of the animation */
  27207. dataType: number;
  27208. /**The loop mode of the animation */
  27209. loopMode?: number | undefined;
  27210. /**Specifies if blending should be enabled */
  27211. enableBlending?: boolean | undefined;
  27212. /**
  27213. * Use matrix interpolation instead of using direct key value when animating matrices
  27214. */
  27215. static AllowMatricesInterpolation: boolean;
  27216. /**
  27217. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27218. */
  27219. static AllowMatrixDecomposeForInterpolation: boolean;
  27220. /**
  27221. * Stores the key frames of the animation
  27222. */
  27223. private _keys;
  27224. /**
  27225. * Stores the easing function of the animation
  27226. */
  27227. private _easingFunction;
  27228. /**
  27229. * @hidden Internal use only
  27230. */
  27231. _runtimeAnimations: RuntimeAnimation[];
  27232. /**
  27233. * The set of event that will be linked to this animation
  27234. */
  27235. private _events;
  27236. /**
  27237. * Stores an array of target property paths
  27238. */
  27239. targetPropertyPath: string[];
  27240. /**
  27241. * Stores the blending speed of the animation
  27242. */
  27243. blendingSpeed: number;
  27244. /**
  27245. * Stores the animation ranges for the animation
  27246. */
  27247. private _ranges;
  27248. /**
  27249. * @hidden Internal use
  27250. */
  27251. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27252. /**
  27253. * Sets up an animation
  27254. * @param property The property to animate
  27255. * @param animationType The animation type to apply
  27256. * @param framePerSecond The frames per second of the animation
  27257. * @param easingFunction The easing function used in the animation
  27258. * @returns The created animation
  27259. */
  27260. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27261. /**
  27262. * Create and start an animation on a node
  27263. * @param name defines the name of the global animation that will be run on all nodes
  27264. * @param node defines the root node where the animation will take place
  27265. * @param targetProperty defines property to animate
  27266. * @param framePerSecond defines the number of frame per second yo use
  27267. * @param totalFrame defines the number of frames in total
  27268. * @param from defines the initial value
  27269. * @param to defines the final value
  27270. * @param loopMode defines which loop mode you want to use (off by default)
  27271. * @param easingFunction defines the easing function to use (linear by default)
  27272. * @param onAnimationEnd defines the callback to call when animation end
  27273. * @returns the animatable created for this animation
  27274. */
  27275. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27276. /**
  27277. * Create and start an animation on a node and its descendants
  27278. * @param name defines the name of the global animation that will be run on all nodes
  27279. * @param node defines the root node where the animation will take place
  27280. * @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
  27281. * @param targetProperty defines property to animate
  27282. * @param framePerSecond defines the number of frame per second to use
  27283. * @param totalFrame defines the number of frames in total
  27284. * @param from defines the initial value
  27285. * @param to defines the final value
  27286. * @param loopMode defines which loop mode you want to use (off by default)
  27287. * @param easingFunction defines the easing function to use (linear by default)
  27288. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27289. * @returns the list of animatables created for all nodes
  27290. * @example https://www.babylonjs-playground.com/#MH0VLI
  27291. */
  27292. 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[]>;
  27293. /**
  27294. * Creates a new animation, merges it with the existing animations and starts it
  27295. * @param name Name of the animation
  27296. * @param node Node which contains the scene that begins the animations
  27297. * @param targetProperty Specifies which property to animate
  27298. * @param framePerSecond The frames per second of the animation
  27299. * @param totalFrame The total number of frames
  27300. * @param from The frame at the beginning of the animation
  27301. * @param to The frame at the end of the animation
  27302. * @param loopMode Specifies the loop mode of the animation
  27303. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27304. * @param onAnimationEnd Callback to run once the animation is complete
  27305. * @returns Nullable animation
  27306. */
  27307. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27308. /**
  27309. * Transition property of an host to the target Value
  27310. * @param property The property to transition
  27311. * @param targetValue The target Value of the property
  27312. * @param host The object where the property to animate belongs
  27313. * @param scene Scene used to run the animation
  27314. * @param frameRate Framerate (in frame/s) to use
  27315. * @param transition The transition type we want to use
  27316. * @param duration The duration of the animation, in milliseconds
  27317. * @param onAnimationEnd Callback trigger at the end of the animation
  27318. * @returns Nullable animation
  27319. */
  27320. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27321. /**
  27322. * Return the array of runtime animations currently using this animation
  27323. */
  27324. readonly runtimeAnimations: RuntimeAnimation[];
  27325. /**
  27326. * Specifies if any of the runtime animations are currently running
  27327. */
  27328. readonly hasRunningRuntimeAnimations: boolean;
  27329. /**
  27330. * Initializes the animation
  27331. * @param name Name of the animation
  27332. * @param targetProperty Property to animate
  27333. * @param framePerSecond The frames per second of the animation
  27334. * @param dataType The data type of the animation
  27335. * @param loopMode The loop mode of the animation
  27336. * @param enableBlending Specifies if blending should be enabled
  27337. */
  27338. constructor(
  27339. /**Name of the animation */
  27340. name: string,
  27341. /**Property to animate */
  27342. targetProperty: string,
  27343. /**The frames per second of the animation */
  27344. framePerSecond: number,
  27345. /**The data type of the animation */
  27346. dataType: number,
  27347. /**The loop mode of the animation */
  27348. loopMode?: number | undefined,
  27349. /**Specifies if blending should be enabled */
  27350. enableBlending?: boolean | undefined);
  27351. /**
  27352. * Converts the animation to a string
  27353. * @param fullDetails support for multiple levels of logging within scene loading
  27354. * @returns String form of the animation
  27355. */
  27356. toString(fullDetails?: boolean): string;
  27357. /**
  27358. * Add an event to this animation
  27359. * @param event Event to add
  27360. */
  27361. addEvent(event: AnimationEvent): void;
  27362. /**
  27363. * Remove all events found at the given frame
  27364. * @param frame The frame to remove events from
  27365. */
  27366. removeEvents(frame: number): void;
  27367. /**
  27368. * Retrieves all the events from the animation
  27369. * @returns Events from the animation
  27370. */
  27371. getEvents(): AnimationEvent[];
  27372. /**
  27373. * Creates an animation range
  27374. * @param name Name of the animation range
  27375. * @param from Starting frame of the animation range
  27376. * @param to Ending frame of the animation
  27377. */
  27378. createRange(name: string, from: number, to: number): void;
  27379. /**
  27380. * Deletes an animation range by name
  27381. * @param name Name of the animation range to delete
  27382. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27383. */
  27384. deleteRange(name: string, deleteFrames?: boolean): void;
  27385. /**
  27386. * Gets the animation range by name, or null if not defined
  27387. * @param name Name of the animation range
  27388. * @returns Nullable animation range
  27389. */
  27390. getRange(name: string): Nullable<AnimationRange>;
  27391. /**
  27392. * Gets the key frames from the animation
  27393. * @returns The key frames of the animation
  27394. */
  27395. getKeys(): Array<IAnimationKey>;
  27396. /**
  27397. * Gets the highest frame rate of the animation
  27398. * @returns Highest frame rate of the animation
  27399. */
  27400. getHighestFrame(): number;
  27401. /**
  27402. * Gets the easing function of the animation
  27403. * @returns Easing function of the animation
  27404. */
  27405. getEasingFunction(): IEasingFunction;
  27406. /**
  27407. * Sets the easing function of the animation
  27408. * @param easingFunction A custom mathematical formula for animation
  27409. */
  27410. setEasingFunction(easingFunction: EasingFunction): void;
  27411. /**
  27412. * Interpolates a scalar linearly
  27413. * @param startValue Start value of the animation curve
  27414. * @param endValue End value of the animation curve
  27415. * @param gradient Scalar amount to interpolate
  27416. * @returns Interpolated scalar value
  27417. */
  27418. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27419. /**
  27420. * Interpolates a scalar cubically
  27421. * @param startValue Start value of the animation curve
  27422. * @param outTangent End tangent of the animation
  27423. * @param endValue End value of the animation curve
  27424. * @param inTangent Start tangent of the animation curve
  27425. * @param gradient Scalar amount to interpolate
  27426. * @returns Interpolated scalar value
  27427. */
  27428. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27429. /**
  27430. * Interpolates a quaternion using a spherical linear interpolation
  27431. * @param startValue Start value of the animation curve
  27432. * @param endValue End value of the animation curve
  27433. * @param gradient Scalar amount to interpolate
  27434. * @returns Interpolated quaternion value
  27435. */
  27436. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27437. /**
  27438. * Interpolates a quaternion cubically
  27439. * @param startValue Start value of the animation curve
  27440. * @param outTangent End tangent of the animation curve
  27441. * @param endValue End value of the animation curve
  27442. * @param inTangent Start tangent of the animation curve
  27443. * @param gradient Scalar amount to interpolate
  27444. * @returns Interpolated quaternion value
  27445. */
  27446. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27447. /**
  27448. * Interpolates a Vector3 linearl
  27449. * @param startValue Start value of the animation curve
  27450. * @param endValue End value of the animation curve
  27451. * @param gradient Scalar amount to interpolate
  27452. * @returns Interpolated scalar value
  27453. */
  27454. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27455. /**
  27456. * Interpolates a Vector3 cubically
  27457. * @param startValue Start value of the animation curve
  27458. * @param outTangent End tangent of the animation
  27459. * @param endValue End value of the animation curve
  27460. * @param inTangent Start tangent of the animation curve
  27461. * @param gradient Scalar amount to interpolate
  27462. * @returns InterpolatedVector3 value
  27463. */
  27464. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27465. /**
  27466. * Interpolates a Vector2 linearly
  27467. * @param startValue Start value of the animation curve
  27468. * @param endValue End value of the animation curve
  27469. * @param gradient Scalar amount to interpolate
  27470. * @returns Interpolated Vector2 value
  27471. */
  27472. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27473. /**
  27474. * Interpolates a Vector2 cubically
  27475. * @param startValue Start value of the animation curve
  27476. * @param outTangent End tangent of the animation
  27477. * @param endValue End value of the animation curve
  27478. * @param inTangent Start tangent of the animation curve
  27479. * @param gradient Scalar amount to interpolate
  27480. * @returns Interpolated Vector2 value
  27481. */
  27482. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27483. /**
  27484. * Interpolates a size linearly
  27485. * @param startValue Start value of the animation curve
  27486. * @param endValue End value of the animation curve
  27487. * @param gradient Scalar amount to interpolate
  27488. * @returns Interpolated Size value
  27489. */
  27490. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27491. /**
  27492. * Interpolates a Color3 linearly
  27493. * @param startValue Start value of the animation curve
  27494. * @param endValue End value of the animation curve
  27495. * @param gradient Scalar amount to interpolate
  27496. * @returns Interpolated Color3 value
  27497. */
  27498. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27499. /**
  27500. * @hidden Internal use only
  27501. */
  27502. _getKeyValue(value: any): any;
  27503. /**
  27504. * @hidden Internal use only
  27505. */
  27506. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27507. /**
  27508. * Defines the function to use to interpolate matrices
  27509. * @param startValue defines the start matrix
  27510. * @param endValue defines the end matrix
  27511. * @param gradient defines the gradient between both matrices
  27512. * @param result defines an optional target matrix where to store the interpolation
  27513. * @returns the interpolated matrix
  27514. */
  27515. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27516. /**
  27517. * Makes a copy of the animation
  27518. * @returns Cloned animation
  27519. */
  27520. clone(): Animation;
  27521. /**
  27522. * Sets the key frames of the animation
  27523. * @param values The animation key frames to set
  27524. */
  27525. setKeys(values: Array<IAnimationKey>): void;
  27526. /**
  27527. * Serializes the animation to an object
  27528. * @returns Serialized object
  27529. */
  27530. serialize(): any;
  27531. /**
  27532. * Float animation type
  27533. */
  27534. private static _ANIMATIONTYPE_FLOAT;
  27535. /**
  27536. * Vector3 animation type
  27537. */
  27538. private static _ANIMATIONTYPE_VECTOR3;
  27539. /**
  27540. * Quaternion animation type
  27541. */
  27542. private static _ANIMATIONTYPE_QUATERNION;
  27543. /**
  27544. * Matrix animation type
  27545. */
  27546. private static _ANIMATIONTYPE_MATRIX;
  27547. /**
  27548. * Color3 animation type
  27549. */
  27550. private static _ANIMATIONTYPE_COLOR3;
  27551. /**
  27552. * Vector2 animation type
  27553. */
  27554. private static _ANIMATIONTYPE_VECTOR2;
  27555. /**
  27556. * Size animation type
  27557. */
  27558. private static _ANIMATIONTYPE_SIZE;
  27559. /**
  27560. * Relative Loop Mode
  27561. */
  27562. private static _ANIMATIONLOOPMODE_RELATIVE;
  27563. /**
  27564. * Cycle Loop Mode
  27565. */
  27566. private static _ANIMATIONLOOPMODE_CYCLE;
  27567. /**
  27568. * Constant Loop Mode
  27569. */
  27570. private static _ANIMATIONLOOPMODE_CONSTANT;
  27571. /**
  27572. * Get the float animation type
  27573. */
  27574. static readonly ANIMATIONTYPE_FLOAT: number;
  27575. /**
  27576. * Get the Vector3 animation type
  27577. */
  27578. static readonly ANIMATIONTYPE_VECTOR3: number;
  27579. /**
  27580. * Get the Vector2 animation type
  27581. */
  27582. static readonly ANIMATIONTYPE_VECTOR2: number;
  27583. /**
  27584. * Get the Size animation type
  27585. */
  27586. static readonly ANIMATIONTYPE_SIZE: number;
  27587. /**
  27588. * Get the Quaternion animation type
  27589. */
  27590. static readonly ANIMATIONTYPE_QUATERNION: number;
  27591. /**
  27592. * Get the Matrix animation type
  27593. */
  27594. static readonly ANIMATIONTYPE_MATRIX: number;
  27595. /**
  27596. * Get the Color3 animation type
  27597. */
  27598. static readonly ANIMATIONTYPE_COLOR3: number;
  27599. /**
  27600. * Get the Relative Loop Mode
  27601. */
  27602. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27603. /**
  27604. * Get the Cycle Loop Mode
  27605. */
  27606. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27607. /**
  27608. * Get the Constant Loop Mode
  27609. */
  27610. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27611. /** @hidden */
  27612. static _UniversalLerp(left: any, right: any, amount: number): any;
  27613. /**
  27614. * Parses an animation object and creates an animation
  27615. * @param parsedAnimation Parsed animation object
  27616. * @returns Animation object
  27617. */
  27618. static Parse(parsedAnimation: any): Animation;
  27619. /**
  27620. * Appends the serialized animations from the source animations
  27621. * @param source Source containing the animations
  27622. * @param destination Target to store the animations
  27623. */
  27624. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27625. }
  27626. }
  27627. declare module BABYLON {
  27628. /**
  27629. * Interface containing an array of animations
  27630. */
  27631. export interface IAnimatable {
  27632. /**
  27633. * Array of animations
  27634. */
  27635. animations: Nullable<Array<Animation>>;
  27636. }
  27637. }
  27638. declare module BABYLON {
  27639. /**
  27640. * This represents all the required information to add a fresnel effect on a material:
  27641. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27642. */
  27643. export class FresnelParameters {
  27644. private _isEnabled;
  27645. /**
  27646. * Define if the fresnel effect is enable or not.
  27647. */
  27648. isEnabled: boolean;
  27649. /**
  27650. * Define the color used on edges (grazing angle)
  27651. */
  27652. leftColor: Color3;
  27653. /**
  27654. * Define the color used on center
  27655. */
  27656. rightColor: Color3;
  27657. /**
  27658. * Define bias applied to computed fresnel term
  27659. */
  27660. bias: number;
  27661. /**
  27662. * Defined the power exponent applied to fresnel term
  27663. */
  27664. power: number;
  27665. /**
  27666. * Clones the current fresnel and its valuues
  27667. * @returns a clone fresnel configuration
  27668. */
  27669. clone(): FresnelParameters;
  27670. /**
  27671. * Serializes the current fresnel parameters to a JSON representation.
  27672. * @return the JSON serialization
  27673. */
  27674. serialize(): any;
  27675. /**
  27676. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27677. * @param parsedFresnelParameters Define the JSON representation
  27678. * @returns the parsed parameters
  27679. */
  27680. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27681. }
  27682. }
  27683. declare module BABYLON {
  27684. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27685. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27686. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27687. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27688. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27689. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27690. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27691. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27692. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27693. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27694. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27695. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27696. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27697. /**
  27698. * Decorator used to define property that can be serialized as reference to a camera
  27699. * @param sourceName defines the name of the property to decorate
  27700. */
  27701. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27702. /**
  27703. * Class used to help serialization objects
  27704. */
  27705. export class SerializationHelper {
  27706. /** @hidden */
  27707. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27708. /** @hidden */
  27709. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27710. /** @hidden */
  27711. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27712. /** @hidden */
  27713. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27714. /**
  27715. * Appends the serialized animations from the source animations
  27716. * @param source Source containing the animations
  27717. * @param destination Target to store the animations
  27718. */
  27719. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27720. /**
  27721. * Static function used to serialized a specific entity
  27722. * @param entity defines the entity to serialize
  27723. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27724. * @returns a JSON compatible object representing the serialization of the entity
  27725. */
  27726. static Serialize<T>(entity: T, serializationObject?: any): any;
  27727. /**
  27728. * Creates a new entity from a serialization data object
  27729. * @param creationFunction defines a function used to instanciated the new entity
  27730. * @param source defines the source serialization data
  27731. * @param scene defines the hosting scene
  27732. * @param rootUrl defines the root url for resources
  27733. * @returns a new entity
  27734. */
  27735. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27736. /**
  27737. * Clones an object
  27738. * @param creationFunction defines the function used to instanciate the new object
  27739. * @param source defines the source object
  27740. * @returns the cloned object
  27741. */
  27742. static Clone<T>(creationFunction: () => T, source: T): T;
  27743. /**
  27744. * Instanciates a new object based on a source one (some data will be shared between both object)
  27745. * @param creationFunction defines the function used to instanciate the new object
  27746. * @param source defines the source object
  27747. * @returns the new object
  27748. */
  27749. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27750. }
  27751. }
  27752. declare module BABYLON {
  27753. /**
  27754. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27755. */
  27756. export interface CubeMapInfo {
  27757. /**
  27758. * The pixel array for the front face.
  27759. * This is stored in format, left to right, up to down format.
  27760. */
  27761. front: Nullable<ArrayBufferView>;
  27762. /**
  27763. * The pixel array for the back face.
  27764. * This is stored in format, left to right, up to down format.
  27765. */
  27766. back: Nullable<ArrayBufferView>;
  27767. /**
  27768. * The pixel array for the left face.
  27769. * This is stored in format, left to right, up to down format.
  27770. */
  27771. left: Nullable<ArrayBufferView>;
  27772. /**
  27773. * The pixel array for the right face.
  27774. * This is stored in format, left to right, up to down format.
  27775. */
  27776. right: Nullable<ArrayBufferView>;
  27777. /**
  27778. * The pixel array for the up face.
  27779. * This is stored in format, left to right, up to down format.
  27780. */
  27781. up: Nullable<ArrayBufferView>;
  27782. /**
  27783. * The pixel array for the down face.
  27784. * This is stored in format, left to right, up to down format.
  27785. */
  27786. down: Nullable<ArrayBufferView>;
  27787. /**
  27788. * The size of the cubemap stored.
  27789. *
  27790. * Each faces will be size * size pixels.
  27791. */
  27792. size: number;
  27793. /**
  27794. * The format of the texture.
  27795. *
  27796. * RGBA, RGB.
  27797. */
  27798. format: number;
  27799. /**
  27800. * The type of the texture data.
  27801. *
  27802. * UNSIGNED_INT, FLOAT.
  27803. */
  27804. type: number;
  27805. /**
  27806. * Specifies whether the texture is in gamma space.
  27807. */
  27808. gammaSpace: boolean;
  27809. }
  27810. /**
  27811. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27812. */
  27813. export class PanoramaToCubeMapTools {
  27814. private static FACE_FRONT;
  27815. private static FACE_BACK;
  27816. private static FACE_RIGHT;
  27817. private static FACE_LEFT;
  27818. private static FACE_DOWN;
  27819. private static FACE_UP;
  27820. /**
  27821. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27822. *
  27823. * @param float32Array The source data.
  27824. * @param inputWidth The width of the input panorama.
  27825. * @param inputHeight The height of the input panorama.
  27826. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27827. * @return The cubemap data
  27828. */
  27829. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27830. private static CreateCubemapTexture;
  27831. private static CalcProjectionSpherical;
  27832. }
  27833. }
  27834. declare module BABYLON {
  27835. /**
  27836. * Helper class dealing with the extraction of spherical polynomial dataArray
  27837. * from a cube map.
  27838. */
  27839. export class CubeMapToSphericalPolynomialTools {
  27840. private static FileFaces;
  27841. /**
  27842. * Converts a texture to the according Spherical Polynomial data.
  27843. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27844. *
  27845. * @param texture The texture to extract the information from.
  27846. * @return The Spherical Polynomial data.
  27847. */
  27848. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27849. /**
  27850. * Converts a cubemap to the according Spherical Polynomial data.
  27851. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27852. *
  27853. * @param cubeInfo The Cube map to extract the information from.
  27854. * @return The Spherical Polynomial data.
  27855. */
  27856. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27857. }
  27858. }
  27859. declare module BABYLON {
  27860. /**
  27861. * Class used to manipulate GUIDs
  27862. */
  27863. export class GUID {
  27864. /**
  27865. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27866. * Be aware Math.random() could cause collisions, but:
  27867. * "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"
  27868. * @returns a pseudo random id
  27869. */
  27870. static RandomId(): string;
  27871. }
  27872. }
  27873. declare module BABYLON {
  27874. /**
  27875. * Base class of all the textures in babylon.
  27876. * It groups all the common properties the materials, post process, lights... might need
  27877. * in order to make a correct use of the texture.
  27878. */
  27879. export class BaseTexture implements IAnimatable {
  27880. /**
  27881. * Default anisotropic filtering level for the application.
  27882. * It is set to 4 as a good tradeoff between perf and quality.
  27883. */
  27884. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27885. /**
  27886. * Gets or sets the unique id of the texture
  27887. */
  27888. uniqueId: number;
  27889. /**
  27890. * Define the name of the texture.
  27891. */
  27892. name: string;
  27893. /**
  27894. * Gets or sets an object used to store user defined information.
  27895. */
  27896. metadata: any;
  27897. /**
  27898. * For internal use only. Please do not use.
  27899. */
  27900. reservedDataStore: any;
  27901. private _hasAlpha;
  27902. /**
  27903. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27904. */
  27905. hasAlpha: boolean;
  27906. /**
  27907. * Defines if the alpha value should be determined via the rgb values.
  27908. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27909. */
  27910. getAlphaFromRGB: boolean;
  27911. /**
  27912. * Intensity or strength of the texture.
  27913. * It is commonly used by materials to fine tune the intensity of the texture
  27914. */
  27915. level: number;
  27916. /**
  27917. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27918. * This is part of the texture as textures usually maps to one uv set.
  27919. */
  27920. coordinatesIndex: number;
  27921. private _coordinatesMode;
  27922. /**
  27923. * How a texture is mapped.
  27924. *
  27925. * | Value | Type | Description |
  27926. * | ----- | ----------------------------------- | ----------- |
  27927. * | 0 | EXPLICIT_MODE | |
  27928. * | 1 | SPHERICAL_MODE | |
  27929. * | 2 | PLANAR_MODE | |
  27930. * | 3 | CUBIC_MODE | |
  27931. * | 4 | PROJECTION_MODE | |
  27932. * | 5 | SKYBOX_MODE | |
  27933. * | 6 | INVCUBIC_MODE | |
  27934. * | 7 | EQUIRECTANGULAR_MODE | |
  27935. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27936. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27937. */
  27938. coordinatesMode: number;
  27939. /**
  27940. * | Value | Type | Description |
  27941. * | ----- | ------------------ | ----------- |
  27942. * | 0 | CLAMP_ADDRESSMODE | |
  27943. * | 1 | WRAP_ADDRESSMODE | |
  27944. * | 2 | MIRROR_ADDRESSMODE | |
  27945. */
  27946. wrapU: number;
  27947. /**
  27948. * | Value | Type | Description |
  27949. * | ----- | ------------------ | ----------- |
  27950. * | 0 | CLAMP_ADDRESSMODE | |
  27951. * | 1 | WRAP_ADDRESSMODE | |
  27952. * | 2 | MIRROR_ADDRESSMODE | |
  27953. */
  27954. wrapV: number;
  27955. /**
  27956. * | Value | Type | Description |
  27957. * | ----- | ------------------ | ----------- |
  27958. * | 0 | CLAMP_ADDRESSMODE | |
  27959. * | 1 | WRAP_ADDRESSMODE | |
  27960. * | 2 | MIRROR_ADDRESSMODE | |
  27961. */
  27962. wrapR: number;
  27963. /**
  27964. * With compliant hardware and browser (supporting anisotropic filtering)
  27965. * this defines the level of anisotropic filtering in the texture.
  27966. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27967. */
  27968. anisotropicFilteringLevel: number;
  27969. /**
  27970. * Define if the texture is a cube texture or if false a 2d texture.
  27971. */
  27972. isCube: boolean;
  27973. /**
  27974. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27975. */
  27976. is3D: boolean;
  27977. /**
  27978. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27979. * HDR texture are usually stored in linear space.
  27980. * This only impacts the PBR and Background materials
  27981. */
  27982. gammaSpace: boolean;
  27983. /**
  27984. * Gets or sets whether or not the texture contains RGBD data.
  27985. */
  27986. isRGBD: boolean;
  27987. /**
  27988. * Is Z inverted in the texture (useful in a cube texture).
  27989. */
  27990. invertZ: boolean;
  27991. /**
  27992. * Are mip maps generated for this texture or not.
  27993. */
  27994. readonly noMipmap: boolean;
  27995. /**
  27996. * @hidden
  27997. */
  27998. lodLevelInAlpha: boolean;
  27999. /**
  28000. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28001. */
  28002. lodGenerationOffset: number;
  28003. /**
  28004. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28005. */
  28006. lodGenerationScale: number;
  28007. /**
  28008. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28009. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28010. * average roughness values.
  28011. */
  28012. linearSpecularLOD: boolean;
  28013. /**
  28014. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28015. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28016. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28017. */
  28018. irradianceTexture: Nullable<BaseTexture>;
  28019. /**
  28020. * Define if the texture is a render target.
  28021. */
  28022. isRenderTarget: boolean;
  28023. /**
  28024. * Define the unique id of the texture in the scene.
  28025. */
  28026. readonly uid: string;
  28027. /**
  28028. * Return a string representation of the texture.
  28029. * @returns the texture as a string
  28030. */
  28031. toString(): string;
  28032. /**
  28033. * Get the class name of the texture.
  28034. * @returns "BaseTexture"
  28035. */
  28036. getClassName(): string;
  28037. /**
  28038. * Define the list of animation attached to the texture.
  28039. */
  28040. animations: Animation[];
  28041. /**
  28042. * An event triggered when the texture is disposed.
  28043. */
  28044. onDisposeObservable: Observable<BaseTexture>;
  28045. private _onDisposeObserver;
  28046. /**
  28047. * Callback triggered when the texture has been disposed.
  28048. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28049. */
  28050. onDispose: () => void;
  28051. /**
  28052. * Define the current state of the loading sequence when in delayed load mode.
  28053. */
  28054. delayLoadState: number;
  28055. private _scene;
  28056. /** @hidden */
  28057. _texture: Nullable<InternalTexture>;
  28058. private _uid;
  28059. /**
  28060. * Define if the texture is preventinga material to render or not.
  28061. * If not and the texture is not ready, the engine will use a default black texture instead.
  28062. */
  28063. readonly isBlocking: boolean;
  28064. /**
  28065. * Instantiates a new BaseTexture.
  28066. * Base class of all the textures in babylon.
  28067. * It groups all the common properties the materials, post process, lights... might need
  28068. * in order to make a correct use of the texture.
  28069. * @param scene Define the scene the texture blongs to
  28070. */
  28071. constructor(scene: Nullable<Scene>);
  28072. /**
  28073. * Get the scene the texture belongs to.
  28074. * @returns the scene or null if undefined
  28075. */
  28076. getScene(): Nullable<Scene>;
  28077. /**
  28078. * Get the texture transform matrix used to offset tile the texture for istance.
  28079. * @returns the transformation matrix
  28080. */
  28081. getTextureMatrix(): Matrix;
  28082. /**
  28083. * Get the texture reflection matrix used to rotate/transform the reflection.
  28084. * @returns the reflection matrix
  28085. */
  28086. getReflectionTextureMatrix(): Matrix;
  28087. /**
  28088. * Get the underlying lower level texture from Babylon.
  28089. * @returns the insternal texture
  28090. */
  28091. getInternalTexture(): Nullable<InternalTexture>;
  28092. /**
  28093. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28094. * @returns true if ready or not blocking
  28095. */
  28096. isReadyOrNotBlocking(): boolean;
  28097. /**
  28098. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28099. * @returns true if fully ready
  28100. */
  28101. isReady(): boolean;
  28102. private _cachedSize;
  28103. /**
  28104. * Get the size of the texture.
  28105. * @returns the texture size.
  28106. */
  28107. getSize(): ISize;
  28108. /**
  28109. * Get the base size of the texture.
  28110. * It can be different from the size if the texture has been resized for POT for instance
  28111. * @returns the base size
  28112. */
  28113. getBaseSize(): ISize;
  28114. /**
  28115. * Update the sampling mode of the texture.
  28116. * Default is Trilinear mode.
  28117. *
  28118. * | Value | Type | Description |
  28119. * | ----- | ------------------ | ----------- |
  28120. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28121. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28122. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28123. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28124. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28125. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28126. * | 7 | NEAREST_LINEAR | |
  28127. * | 8 | NEAREST_NEAREST | |
  28128. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28129. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28130. * | 11 | LINEAR_LINEAR | |
  28131. * | 12 | LINEAR_NEAREST | |
  28132. *
  28133. * > _mag_: magnification filter (close to the viewer)
  28134. * > _min_: minification filter (far from the viewer)
  28135. * > _mip_: filter used between mip map levels
  28136. *@param samplingMode Define the new sampling mode of the texture
  28137. */
  28138. updateSamplingMode(samplingMode: number): void;
  28139. /**
  28140. * Scales the texture if is `canRescale()`
  28141. * @param ratio the resize factor we want to use to rescale
  28142. */
  28143. scale(ratio: number): void;
  28144. /**
  28145. * Get if the texture can rescale.
  28146. */
  28147. readonly canRescale: boolean;
  28148. /** @hidden */
  28149. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28150. /** @hidden */
  28151. _rebuild(): void;
  28152. /**
  28153. * Triggers the load sequence in delayed load mode.
  28154. */
  28155. delayLoad(): void;
  28156. /**
  28157. * Clones the texture.
  28158. * @returns the cloned texture
  28159. */
  28160. clone(): Nullable<BaseTexture>;
  28161. /**
  28162. * Get the texture underlying type (INT, FLOAT...)
  28163. */
  28164. readonly textureType: number;
  28165. /**
  28166. * Get the texture underlying format (RGB, RGBA...)
  28167. */
  28168. readonly textureFormat: number;
  28169. /**
  28170. * Indicates that textures need to be re-calculated for all materials
  28171. */
  28172. protected _markAllSubMeshesAsTexturesDirty(): void;
  28173. /**
  28174. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28175. * This will returns an RGBA array buffer containing either in values (0-255) or
  28176. * float values (0-1) depending of the underlying buffer type.
  28177. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28178. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28179. * @param buffer defines a user defined buffer to fill with data (can be null)
  28180. * @returns The Array buffer containing the pixels data.
  28181. */
  28182. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28183. /**
  28184. * Release and destroy the underlying lower level texture aka internalTexture.
  28185. */
  28186. releaseInternalTexture(): void;
  28187. /**
  28188. * Get the polynomial representation of the texture data.
  28189. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28190. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28191. */
  28192. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28193. /** @hidden */
  28194. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28195. /** @hidden */
  28196. readonly _lodTextureMid: Nullable<BaseTexture>;
  28197. /** @hidden */
  28198. readonly _lodTextureLow: Nullable<BaseTexture>;
  28199. /**
  28200. * Dispose the texture and release its associated resources.
  28201. */
  28202. dispose(): void;
  28203. /**
  28204. * Serialize the texture into a JSON representation that can be parsed later on.
  28205. * @returns the JSON representation of the texture
  28206. */
  28207. serialize(): any;
  28208. /**
  28209. * Helper function to be called back once a list of texture contains only ready textures.
  28210. * @param textures Define the list of textures to wait for
  28211. * @param callback Define the callback triggered once the entire list will be ready
  28212. */
  28213. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28214. }
  28215. }
  28216. declare module BABYLON {
  28217. /**
  28218. * Options to be used when creating an effect.
  28219. */
  28220. export class EffectCreationOptions {
  28221. /**
  28222. * Atrributes that will be used in the shader.
  28223. */
  28224. attributes: string[];
  28225. /**
  28226. * Uniform varible names that will be set in the shader.
  28227. */
  28228. uniformsNames: string[];
  28229. /**
  28230. * Uniform buffer varible names that will be set in the shader.
  28231. */
  28232. uniformBuffersNames: string[];
  28233. /**
  28234. * Sampler texture variable names that will be set in the shader.
  28235. */
  28236. samplers: string[];
  28237. /**
  28238. * Define statements that will be set in the shader.
  28239. */
  28240. defines: any;
  28241. /**
  28242. * Possible fallbacks for this effect to improve performance when needed.
  28243. */
  28244. fallbacks: Nullable<IEffectFallbacks>;
  28245. /**
  28246. * Callback that will be called when the shader is compiled.
  28247. */
  28248. onCompiled: Nullable<(effect: Effect) => void>;
  28249. /**
  28250. * Callback that will be called if an error occurs during shader compilation.
  28251. */
  28252. onError: Nullable<(effect: Effect, errors: string) => void>;
  28253. /**
  28254. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28255. */
  28256. indexParameters?: any;
  28257. /**
  28258. * Max number of lights that can be used in the shader.
  28259. */
  28260. maxSimultaneousLights?: number;
  28261. /**
  28262. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28263. */
  28264. transformFeedbackVaryings?: Nullable<string[]>;
  28265. }
  28266. /**
  28267. * Effect containing vertex and fragment shader that can be executed on an object.
  28268. */
  28269. export class Effect implements IDisposable {
  28270. /**
  28271. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28272. */
  28273. static ShadersRepository: string;
  28274. /**
  28275. * Name of the effect.
  28276. */
  28277. name: any;
  28278. /**
  28279. * String container all the define statements that should be set on the shader.
  28280. */
  28281. defines: string;
  28282. /**
  28283. * Callback that will be called when the shader is compiled.
  28284. */
  28285. onCompiled: Nullable<(effect: Effect) => void>;
  28286. /**
  28287. * Callback that will be called if an error occurs during shader compilation.
  28288. */
  28289. onError: Nullable<(effect: Effect, errors: string) => void>;
  28290. /**
  28291. * Callback that will be called when effect is bound.
  28292. */
  28293. onBind: Nullable<(effect: Effect) => void>;
  28294. /**
  28295. * Unique ID of the effect.
  28296. */
  28297. uniqueId: number;
  28298. /**
  28299. * Observable that will be called when the shader is compiled.
  28300. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28301. */
  28302. onCompileObservable: Observable<Effect>;
  28303. /**
  28304. * Observable that will be called if an error occurs during shader compilation.
  28305. */
  28306. onErrorObservable: Observable<Effect>;
  28307. /** @hidden */
  28308. _onBindObservable: Nullable<Observable<Effect>>;
  28309. /**
  28310. * Observable that will be called when effect is bound.
  28311. */
  28312. readonly onBindObservable: Observable<Effect>;
  28313. /** @hidden */
  28314. _bonesComputationForcedToCPU: boolean;
  28315. private static _uniqueIdSeed;
  28316. private _engine;
  28317. private _uniformBuffersNames;
  28318. private _uniformsNames;
  28319. private _samplerList;
  28320. private _samplers;
  28321. private _isReady;
  28322. private _compilationError;
  28323. private _attributesNames;
  28324. private _attributes;
  28325. private _uniforms;
  28326. /**
  28327. * Key for the effect.
  28328. * @hidden
  28329. */
  28330. _key: string;
  28331. private _indexParameters;
  28332. private _fallbacks;
  28333. private _vertexSourceCode;
  28334. private _fragmentSourceCode;
  28335. private _vertexSourceCodeOverride;
  28336. private _fragmentSourceCodeOverride;
  28337. private _transformFeedbackVaryings;
  28338. /**
  28339. * Compiled shader to webGL program.
  28340. * @hidden
  28341. */
  28342. _pipelineContext: Nullable<IPipelineContext>;
  28343. private _valueCache;
  28344. private static _baseCache;
  28345. /**
  28346. * Instantiates an effect.
  28347. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28348. * @param baseName Name of the effect.
  28349. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28350. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28351. * @param samplers List of sampler variables that will be passed to the shader.
  28352. * @param engine Engine to be used to render the effect
  28353. * @param defines Define statements to be added to the shader.
  28354. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28355. * @param onCompiled Callback that will be called when the shader is compiled.
  28356. * @param onError Callback that will be called if an error occurs during shader compilation.
  28357. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28358. */
  28359. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28360. private _useFinalCode;
  28361. /**
  28362. * Unique key for this effect
  28363. */
  28364. readonly key: string;
  28365. /**
  28366. * If the effect has been compiled and prepared.
  28367. * @returns if the effect is compiled and prepared.
  28368. */
  28369. isReady(): boolean;
  28370. private _isReadyInternal;
  28371. /**
  28372. * The engine the effect was initialized with.
  28373. * @returns the engine.
  28374. */
  28375. getEngine(): Engine;
  28376. /**
  28377. * The pipeline context for this effect
  28378. * @returns the associated pipeline context
  28379. */
  28380. getPipelineContext(): Nullable<IPipelineContext>;
  28381. /**
  28382. * The set of names of attribute variables for the shader.
  28383. * @returns An array of attribute names.
  28384. */
  28385. getAttributesNames(): string[];
  28386. /**
  28387. * Returns the attribute at the given index.
  28388. * @param index The index of the attribute.
  28389. * @returns The location of the attribute.
  28390. */
  28391. getAttributeLocation(index: number): number;
  28392. /**
  28393. * Returns the attribute based on the name of the variable.
  28394. * @param name of the attribute to look up.
  28395. * @returns the attribute location.
  28396. */
  28397. getAttributeLocationByName(name: string): number;
  28398. /**
  28399. * The number of attributes.
  28400. * @returns the numnber of attributes.
  28401. */
  28402. getAttributesCount(): number;
  28403. /**
  28404. * Gets the index of a uniform variable.
  28405. * @param uniformName of the uniform to look up.
  28406. * @returns the index.
  28407. */
  28408. getUniformIndex(uniformName: string): number;
  28409. /**
  28410. * Returns the attribute based on the name of the variable.
  28411. * @param uniformName of the uniform to look up.
  28412. * @returns the location of the uniform.
  28413. */
  28414. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28415. /**
  28416. * Returns an array of sampler variable names
  28417. * @returns The array of sampler variable neames.
  28418. */
  28419. getSamplers(): string[];
  28420. /**
  28421. * The error from the last compilation.
  28422. * @returns the error string.
  28423. */
  28424. getCompilationError(): string;
  28425. /**
  28426. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28427. * @param func The callback to be used.
  28428. */
  28429. executeWhenCompiled(func: (effect: Effect) => void): void;
  28430. private _checkIsReady;
  28431. /** @hidden */
  28432. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28433. /** @hidden */
  28434. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28435. /** @hidden */
  28436. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28437. /**
  28438. * Recompiles the webGL program
  28439. * @param vertexSourceCode The source code for the vertex shader.
  28440. * @param fragmentSourceCode The source code for the fragment shader.
  28441. * @param onCompiled Callback called when completed.
  28442. * @param onError Callback called on error.
  28443. * @hidden
  28444. */
  28445. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28446. /**
  28447. * Prepares the effect
  28448. * @hidden
  28449. */
  28450. _prepareEffect(): void;
  28451. private _processCompilationErrors;
  28452. /**
  28453. * Checks if the effect is supported. (Must be called after compilation)
  28454. */
  28455. readonly isSupported: boolean;
  28456. /**
  28457. * Binds a texture to the engine to be used as output of the shader.
  28458. * @param channel Name of the output variable.
  28459. * @param texture Texture to bind.
  28460. * @hidden
  28461. */
  28462. _bindTexture(channel: string, texture: InternalTexture): void;
  28463. /**
  28464. * Sets a texture on the engine to be used in the shader.
  28465. * @param channel Name of the sampler variable.
  28466. * @param texture Texture to set.
  28467. */
  28468. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28469. /**
  28470. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28471. * @param channel Name of the sampler variable.
  28472. * @param texture Texture to set.
  28473. */
  28474. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28475. /**
  28476. * Sets an array of textures on the engine to be used in the shader.
  28477. * @param channel Name of the variable.
  28478. * @param textures Textures to set.
  28479. */
  28480. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28481. /**
  28482. * 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)
  28483. * @param channel Name of the sampler variable.
  28484. * @param postProcess Post process to get the input texture from.
  28485. */
  28486. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28487. /**
  28488. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28489. * 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)
  28490. * @param channel Name of the sampler variable.
  28491. * @param postProcess Post process to get the output texture from.
  28492. */
  28493. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28494. /** @hidden */
  28495. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28496. /** @hidden */
  28497. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28498. /** @hidden */
  28499. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28500. /** @hidden */
  28501. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28502. /**
  28503. * Binds a buffer to a uniform.
  28504. * @param buffer Buffer to bind.
  28505. * @param name Name of the uniform variable to bind to.
  28506. */
  28507. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28508. /**
  28509. * Binds block to a uniform.
  28510. * @param blockName Name of the block to bind.
  28511. * @param index Index to bind.
  28512. */
  28513. bindUniformBlock(blockName: string, index: number): void;
  28514. /**
  28515. * Sets an interger value on a uniform variable.
  28516. * @param uniformName Name of the variable.
  28517. * @param value Value to be set.
  28518. * @returns this effect.
  28519. */
  28520. setInt(uniformName: string, value: number): Effect;
  28521. /**
  28522. * Sets an int array on a uniform variable.
  28523. * @param uniformName Name of the variable.
  28524. * @param array array to be set.
  28525. * @returns this effect.
  28526. */
  28527. setIntArray(uniformName: string, array: Int32Array): Effect;
  28528. /**
  28529. * 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)
  28530. * @param uniformName Name of the variable.
  28531. * @param array array to be set.
  28532. * @returns this effect.
  28533. */
  28534. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28535. /**
  28536. * 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)
  28537. * @param uniformName Name of the variable.
  28538. * @param array array to be set.
  28539. * @returns this effect.
  28540. */
  28541. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28542. /**
  28543. * 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)
  28544. * @param uniformName Name of the variable.
  28545. * @param array array to be set.
  28546. * @returns this effect.
  28547. */
  28548. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28549. /**
  28550. * Sets an float array on a uniform variable.
  28551. * @param uniformName Name of the variable.
  28552. * @param array array to be set.
  28553. * @returns this effect.
  28554. */
  28555. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28556. /**
  28557. * 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)
  28558. * @param uniformName Name of the variable.
  28559. * @param array array to be set.
  28560. * @returns this effect.
  28561. */
  28562. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28563. /**
  28564. * 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)
  28565. * @param uniformName Name of the variable.
  28566. * @param array array to be set.
  28567. * @returns this effect.
  28568. */
  28569. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28570. /**
  28571. * 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)
  28572. * @param uniformName Name of the variable.
  28573. * @param array array to be set.
  28574. * @returns this effect.
  28575. */
  28576. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28577. /**
  28578. * Sets an array on a uniform variable.
  28579. * @param uniformName Name of the variable.
  28580. * @param array array to be set.
  28581. * @returns this effect.
  28582. */
  28583. setArray(uniformName: string, array: number[]): Effect;
  28584. /**
  28585. * 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)
  28586. * @param uniformName Name of the variable.
  28587. * @param array array to be set.
  28588. * @returns this effect.
  28589. */
  28590. setArray2(uniformName: string, array: number[]): Effect;
  28591. /**
  28592. * 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)
  28593. * @param uniformName Name of the variable.
  28594. * @param array array to be set.
  28595. * @returns this effect.
  28596. */
  28597. setArray3(uniformName: string, array: number[]): Effect;
  28598. /**
  28599. * 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)
  28600. * @param uniformName Name of the variable.
  28601. * @param array array to be set.
  28602. * @returns this effect.
  28603. */
  28604. setArray4(uniformName: string, array: number[]): Effect;
  28605. /**
  28606. * Sets matrices on a uniform variable.
  28607. * @param uniformName Name of the variable.
  28608. * @param matrices matrices to be set.
  28609. * @returns this effect.
  28610. */
  28611. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28612. /**
  28613. * Sets matrix on a uniform variable.
  28614. * @param uniformName Name of the variable.
  28615. * @param matrix matrix to be set.
  28616. * @returns this effect.
  28617. */
  28618. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28619. /**
  28620. * 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)
  28621. * @param uniformName Name of the variable.
  28622. * @param matrix matrix to be set.
  28623. * @returns this effect.
  28624. */
  28625. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28626. /**
  28627. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28628. * @param uniformName Name of the variable.
  28629. * @param matrix matrix to be set.
  28630. * @returns this effect.
  28631. */
  28632. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28633. /**
  28634. * Sets a float on a uniform variable.
  28635. * @param uniformName Name of the variable.
  28636. * @param value value to be set.
  28637. * @returns this effect.
  28638. */
  28639. setFloat(uniformName: string, value: number): Effect;
  28640. /**
  28641. * Sets a boolean on a uniform variable.
  28642. * @param uniformName Name of the variable.
  28643. * @param bool value to be set.
  28644. * @returns this effect.
  28645. */
  28646. setBool(uniformName: string, bool: boolean): Effect;
  28647. /**
  28648. * Sets a Vector2 on a uniform variable.
  28649. * @param uniformName Name of the variable.
  28650. * @param vector2 vector2 to be set.
  28651. * @returns this effect.
  28652. */
  28653. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28654. /**
  28655. * Sets a float2 on a uniform variable.
  28656. * @param uniformName Name of the variable.
  28657. * @param x First float in float2.
  28658. * @param y Second float in float2.
  28659. * @returns this effect.
  28660. */
  28661. setFloat2(uniformName: string, x: number, y: number): Effect;
  28662. /**
  28663. * Sets a Vector3 on a uniform variable.
  28664. * @param uniformName Name of the variable.
  28665. * @param vector3 Value to be set.
  28666. * @returns this effect.
  28667. */
  28668. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28669. /**
  28670. * Sets a float3 on a uniform variable.
  28671. * @param uniformName Name of the variable.
  28672. * @param x First float in float3.
  28673. * @param y Second float in float3.
  28674. * @param z Third float in float3.
  28675. * @returns this effect.
  28676. */
  28677. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28678. /**
  28679. * Sets a Vector4 on a uniform variable.
  28680. * @param uniformName Name of the variable.
  28681. * @param vector4 Value to be set.
  28682. * @returns this effect.
  28683. */
  28684. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28685. /**
  28686. * Sets a float4 on a uniform variable.
  28687. * @param uniformName Name of the variable.
  28688. * @param x First float in float4.
  28689. * @param y Second float in float4.
  28690. * @param z Third float in float4.
  28691. * @param w Fourth float in float4.
  28692. * @returns this effect.
  28693. */
  28694. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28695. /**
  28696. * Sets a Color3 on a uniform variable.
  28697. * @param uniformName Name of the variable.
  28698. * @param color3 Value to be set.
  28699. * @returns this effect.
  28700. */
  28701. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28702. /**
  28703. * Sets a Color4 on a uniform variable.
  28704. * @param uniformName Name of the variable.
  28705. * @param color3 Value to be set.
  28706. * @param alpha Alpha value to be set.
  28707. * @returns this effect.
  28708. */
  28709. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28710. /**
  28711. * Sets a Color4 on a uniform variable
  28712. * @param uniformName defines the name of the variable
  28713. * @param color4 defines the value to be set
  28714. * @returns this effect.
  28715. */
  28716. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28717. /** Release all associated resources */
  28718. dispose(): void;
  28719. /**
  28720. * This function will add a new shader to the shader store
  28721. * @param name the name of the shader
  28722. * @param pixelShader optional pixel shader content
  28723. * @param vertexShader optional vertex shader content
  28724. */
  28725. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28726. /**
  28727. * Store of each shader (The can be looked up using effect.key)
  28728. */
  28729. static ShadersStore: {
  28730. [key: string]: string;
  28731. };
  28732. /**
  28733. * Store of each included file for a shader (The can be looked up using effect.key)
  28734. */
  28735. static IncludesShadersStore: {
  28736. [key: string]: string;
  28737. };
  28738. /**
  28739. * Resets the cache of effects.
  28740. */
  28741. static ResetCache(): void;
  28742. }
  28743. }
  28744. declare module BABYLON {
  28745. /**
  28746. * Class used to describe the capabilities of the engine relatively to the current browser
  28747. */
  28748. export class EngineCapabilities {
  28749. /** Maximum textures units per fragment shader */
  28750. maxTexturesImageUnits: number;
  28751. /** Maximum texture units per vertex shader */
  28752. maxVertexTextureImageUnits: number;
  28753. /** Maximum textures units in the entire pipeline */
  28754. maxCombinedTexturesImageUnits: number;
  28755. /** Maximum texture size */
  28756. maxTextureSize: number;
  28757. /** Maximum cube texture size */
  28758. maxCubemapTextureSize: number;
  28759. /** Maximum render texture size */
  28760. maxRenderTextureSize: number;
  28761. /** Maximum number of vertex attributes */
  28762. maxVertexAttribs: number;
  28763. /** Maximum number of varyings */
  28764. maxVaryingVectors: number;
  28765. /** Maximum number of uniforms per vertex shader */
  28766. maxVertexUniformVectors: number;
  28767. /** Maximum number of uniforms per fragment shader */
  28768. maxFragmentUniformVectors: number;
  28769. /** Defines if standard derivates (dx/dy) are supported */
  28770. standardDerivatives: boolean;
  28771. /** Defines if s3tc texture compression is supported */
  28772. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28773. /** Defines if pvrtc texture compression is supported */
  28774. pvrtc: any;
  28775. /** Defines if etc1 texture compression is supported */
  28776. etc1: any;
  28777. /** Defines if etc2 texture compression is supported */
  28778. etc2: any;
  28779. /** Defines if astc texture compression is supported */
  28780. astc: any;
  28781. /** Defines if float textures are supported */
  28782. textureFloat: boolean;
  28783. /** Defines if vertex array objects are supported */
  28784. vertexArrayObject: boolean;
  28785. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28786. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28787. /** Gets the maximum level of anisotropy supported */
  28788. maxAnisotropy: number;
  28789. /** Defines if instancing is supported */
  28790. instancedArrays: boolean;
  28791. /** Defines if 32 bits indices are supported */
  28792. uintIndices: boolean;
  28793. /** Defines if high precision shaders are supported */
  28794. highPrecisionShaderSupported: boolean;
  28795. /** Defines if depth reading in the fragment shader is supported */
  28796. fragmentDepthSupported: boolean;
  28797. /** Defines if float texture linear filtering is supported*/
  28798. textureFloatLinearFiltering: boolean;
  28799. /** Defines if rendering to float textures is supported */
  28800. textureFloatRender: boolean;
  28801. /** Defines if half float textures are supported*/
  28802. textureHalfFloat: boolean;
  28803. /** Defines if half float texture linear filtering is supported*/
  28804. textureHalfFloatLinearFiltering: boolean;
  28805. /** Defines if rendering to half float textures is supported */
  28806. textureHalfFloatRender: boolean;
  28807. /** Defines if textureLOD shader command is supported */
  28808. textureLOD: boolean;
  28809. /** Defines if draw buffers extension is supported */
  28810. drawBuffersExtension: boolean;
  28811. /** Defines if depth textures are supported */
  28812. depthTextureExtension: boolean;
  28813. /** Defines if float color buffer are supported */
  28814. colorBufferFloat: boolean;
  28815. /** Gets disjoint timer query extension (null if not supported) */
  28816. timerQuery: EXT_disjoint_timer_query;
  28817. /** Defines if timestamp can be used with timer query */
  28818. canUseTimestampForTimerQuery: boolean;
  28819. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28820. multiview: any;
  28821. /** Function used to let the system compiles shaders in background */
  28822. parallelShaderCompile: {
  28823. COMPLETION_STATUS_KHR: number;
  28824. };
  28825. /** Max number of texture samples for MSAA */
  28826. maxMSAASamples: number;
  28827. /** Defines if the blend min max extension is supported */
  28828. blendMinMax: boolean;
  28829. }
  28830. }
  28831. declare module BABYLON {
  28832. /**
  28833. * @hidden
  28834. **/
  28835. export class DepthCullingState {
  28836. private _isDepthTestDirty;
  28837. private _isDepthMaskDirty;
  28838. private _isDepthFuncDirty;
  28839. private _isCullFaceDirty;
  28840. private _isCullDirty;
  28841. private _isZOffsetDirty;
  28842. private _isFrontFaceDirty;
  28843. private _depthTest;
  28844. private _depthMask;
  28845. private _depthFunc;
  28846. private _cull;
  28847. private _cullFace;
  28848. private _zOffset;
  28849. private _frontFace;
  28850. /**
  28851. * Initializes the state.
  28852. */
  28853. constructor();
  28854. readonly isDirty: boolean;
  28855. zOffset: number;
  28856. cullFace: Nullable<number>;
  28857. cull: Nullable<boolean>;
  28858. depthFunc: Nullable<number>;
  28859. depthMask: boolean;
  28860. depthTest: boolean;
  28861. frontFace: Nullable<number>;
  28862. reset(): void;
  28863. apply(gl: WebGLRenderingContext): void;
  28864. }
  28865. }
  28866. declare module BABYLON {
  28867. /**
  28868. * @hidden
  28869. **/
  28870. export class StencilState {
  28871. /** 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 */
  28872. static readonly ALWAYS: number;
  28873. /** Passed to stencilOperation to specify that stencil value must be kept */
  28874. static readonly KEEP: number;
  28875. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28876. static readonly REPLACE: number;
  28877. private _isStencilTestDirty;
  28878. private _isStencilMaskDirty;
  28879. private _isStencilFuncDirty;
  28880. private _isStencilOpDirty;
  28881. private _stencilTest;
  28882. private _stencilMask;
  28883. private _stencilFunc;
  28884. private _stencilFuncRef;
  28885. private _stencilFuncMask;
  28886. private _stencilOpStencilFail;
  28887. private _stencilOpDepthFail;
  28888. private _stencilOpStencilDepthPass;
  28889. readonly isDirty: boolean;
  28890. stencilFunc: number;
  28891. stencilFuncRef: number;
  28892. stencilFuncMask: number;
  28893. stencilOpStencilFail: number;
  28894. stencilOpDepthFail: number;
  28895. stencilOpStencilDepthPass: number;
  28896. stencilMask: number;
  28897. stencilTest: boolean;
  28898. constructor();
  28899. reset(): void;
  28900. apply(gl: WebGLRenderingContext): void;
  28901. }
  28902. }
  28903. declare module BABYLON {
  28904. /**
  28905. * @hidden
  28906. **/
  28907. export class AlphaState {
  28908. private _isAlphaBlendDirty;
  28909. private _isBlendFunctionParametersDirty;
  28910. private _isBlendEquationParametersDirty;
  28911. private _isBlendConstantsDirty;
  28912. private _alphaBlend;
  28913. private _blendFunctionParameters;
  28914. private _blendEquationParameters;
  28915. private _blendConstants;
  28916. /**
  28917. * Initializes the state.
  28918. */
  28919. constructor();
  28920. readonly isDirty: boolean;
  28921. alphaBlend: boolean;
  28922. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28923. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28924. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28925. reset(): void;
  28926. apply(gl: WebGLRenderingContext): void;
  28927. }
  28928. }
  28929. declare module BABYLON {
  28930. /** @hidden */
  28931. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28932. attributeProcessor(attribute: string): string;
  28933. varyingProcessor(varying: string, isFragment: boolean): string;
  28934. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28935. }
  28936. }
  28937. declare module BABYLON {
  28938. /**
  28939. * Interface for attribute information associated with buffer instanciation
  28940. */
  28941. export class InstancingAttributeInfo {
  28942. /**
  28943. * Index/offset of the attribute in the vertex shader
  28944. */
  28945. index: number;
  28946. /**
  28947. * size of the attribute, 1, 2, 3 or 4
  28948. */
  28949. attributeSize: number;
  28950. /**
  28951. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28952. * default is FLOAT
  28953. */
  28954. attribyteType: number;
  28955. /**
  28956. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28957. */
  28958. normalized: boolean;
  28959. /**
  28960. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28961. */
  28962. offset: number;
  28963. /**
  28964. * Name of the GLSL attribute, for debugging purpose only
  28965. */
  28966. attributeName: string;
  28967. }
  28968. }
  28969. declare module BABYLON {
  28970. interface ThinEngine {
  28971. /**
  28972. * Update a video texture
  28973. * @param texture defines the texture to update
  28974. * @param video defines the video element to use
  28975. * @param invertY defines if data must be stored with Y axis inverted
  28976. */
  28977. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28978. }
  28979. }
  28980. declare module BABYLON {
  28981. /**
  28982. * Settings for finer control over video usage
  28983. */
  28984. export interface VideoTextureSettings {
  28985. /**
  28986. * Applies `autoplay` to video, if specified
  28987. */
  28988. autoPlay?: boolean;
  28989. /**
  28990. * Applies `loop` to video, if specified
  28991. */
  28992. loop?: boolean;
  28993. /**
  28994. * Automatically updates internal texture from video at every frame in the render loop
  28995. */
  28996. autoUpdateTexture: boolean;
  28997. /**
  28998. * Image src displayed during the video loading or until the user interacts with the video.
  28999. */
  29000. poster?: string;
  29001. }
  29002. /**
  29003. * If you want to display a video in your scene, this is the special texture for that.
  29004. * This special texture works similar to other textures, with the exception of a few parameters.
  29005. * @see https://doc.babylonjs.com/how_to/video_texture
  29006. */
  29007. export class VideoTexture extends Texture {
  29008. /**
  29009. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29010. */
  29011. readonly autoUpdateTexture: boolean;
  29012. /**
  29013. * The video instance used by the texture internally
  29014. */
  29015. readonly video: HTMLVideoElement;
  29016. private _onUserActionRequestedObservable;
  29017. /**
  29018. * Event triggerd when a dom action is required by the user to play the video.
  29019. * This happens due to recent changes in browser policies preventing video to auto start.
  29020. */
  29021. readonly onUserActionRequestedObservable: Observable<Texture>;
  29022. private _generateMipMaps;
  29023. private _engine;
  29024. private _stillImageCaptured;
  29025. private _displayingPosterTexture;
  29026. private _settings;
  29027. private _createInternalTextureOnEvent;
  29028. private _frameId;
  29029. /**
  29030. * Creates a video texture.
  29031. * If you want to display a video in your scene, this is the special texture for that.
  29032. * This special texture works similar to other textures, with the exception of a few parameters.
  29033. * @see https://doc.babylonjs.com/how_to/video_texture
  29034. * @param name optional name, will detect from video source, if not defined
  29035. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29036. * @param scene is obviously the current scene.
  29037. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29038. * @param invertY is false by default but can be used to invert video on Y axis
  29039. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29040. * @param settings allows finer control over video usage
  29041. */
  29042. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29043. private _getName;
  29044. private _getVideo;
  29045. private _createInternalTexture;
  29046. private reset;
  29047. /**
  29048. * @hidden Internal method to initiate `update`.
  29049. */
  29050. _rebuild(): void;
  29051. /**
  29052. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29053. */
  29054. update(): void;
  29055. /**
  29056. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29057. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29058. */
  29059. updateTexture(isVisible: boolean): void;
  29060. protected _updateInternalTexture: () => void;
  29061. /**
  29062. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29063. * @param url New url.
  29064. */
  29065. updateURL(url: string): void;
  29066. /**
  29067. * Dispose the texture and release its associated resources.
  29068. */
  29069. dispose(): void;
  29070. /**
  29071. * Creates a video texture straight from a stream.
  29072. * @param scene Define the scene the texture should be created in
  29073. * @param stream Define the stream the texture should be created from
  29074. * @returns The created video texture as a promise
  29075. */
  29076. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29077. /**
  29078. * Creates a video texture straight from your WebCam video feed.
  29079. * @param scene Define the scene the texture should be created in
  29080. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29081. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29082. * @returns The created video texture as a promise
  29083. */
  29084. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29085. minWidth: number;
  29086. maxWidth: number;
  29087. minHeight: number;
  29088. maxHeight: number;
  29089. deviceId: string;
  29090. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29091. /**
  29092. * Creates a video texture straight from your WebCam video feed.
  29093. * @param scene Define the scene the texture should be created in
  29094. * @param onReady Define a callback to triggered once the texture will be ready
  29095. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29096. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29097. */
  29098. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29099. minWidth: number;
  29100. maxWidth: number;
  29101. minHeight: number;
  29102. maxHeight: number;
  29103. deviceId: string;
  29104. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29105. }
  29106. }
  29107. declare module BABYLON {
  29108. /**
  29109. * Defines the interface used by objects working like Scene
  29110. * @hidden
  29111. */
  29112. interface ISceneLike {
  29113. _addPendingData(data: any): void;
  29114. _removePendingData(data: any): void;
  29115. offlineProvider: IOfflineProvider;
  29116. }
  29117. /** Interface defining initialization parameters for Engine class */
  29118. export interface EngineOptions extends WebGLContextAttributes {
  29119. /**
  29120. * Defines if the engine should no exceed a specified device ratio
  29121. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29122. */
  29123. limitDeviceRatio?: number;
  29124. /**
  29125. * Defines if webvr should be enabled automatically
  29126. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29127. */
  29128. autoEnableWebVR?: boolean;
  29129. /**
  29130. * Defines if webgl2 should be turned off even if supported
  29131. * @see http://doc.babylonjs.com/features/webgl2
  29132. */
  29133. disableWebGL2Support?: boolean;
  29134. /**
  29135. * Defines if webaudio should be initialized as well
  29136. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29137. */
  29138. audioEngine?: boolean;
  29139. /**
  29140. * Defines if animations should run using a deterministic lock step
  29141. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29142. */
  29143. deterministicLockstep?: boolean;
  29144. /** Defines the maximum steps to use with deterministic lock step mode */
  29145. lockstepMaxSteps?: number;
  29146. /**
  29147. * Defines that engine should ignore context lost events
  29148. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29149. */
  29150. doNotHandleContextLost?: boolean;
  29151. /**
  29152. * Defines that engine should ignore modifying touch action attribute and style
  29153. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29154. */
  29155. doNotHandleTouchAction?: boolean;
  29156. /**
  29157. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29158. */
  29159. useHighPrecisionFloats?: boolean;
  29160. }
  29161. /**
  29162. * The base engine class (root of all engines)
  29163. */
  29164. export class ThinEngine {
  29165. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29166. static ExceptionList: ({
  29167. key: string;
  29168. capture: string;
  29169. captureConstraint: number;
  29170. targets: string[];
  29171. } | {
  29172. key: string;
  29173. capture: null;
  29174. captureConstraint: null;
  29175. targets: string[];
  29176. })[];
  29177. /** @hidden */
  29178. static _TextureLoaders: IInternalTextureLoader[];
  29179. /**
  29180. * Returns the current npm package of the sdk
  29181. */
  29182. static readonly NpmPackage: string;
  29183. /**
  29184. * Returns the current version of the framework
  29185. */
  29186. static readonly Version: string;
  29187. /**
  29188. * Returns a string describing the current engine
  29189. */
  29190. readonly description: string;
  29191. /**
  29192. * Gets or sets the epsilon value used by collision engine
  29193. */
  29194. static CollisionsEpsilon: number;
  29195. /**
  29196. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29197. */
  29198. static ShadersRepository: string;
  29199. /** @hidden */
  29200. _shaderProcessor: IShaderProcessor;
  29201. /**
  29202. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29203. */
  29204. forcePOTTextures: boolean;
  29205. /**
  29206. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29207. */
  29208. isFullscreen: boolean;
  29209. /**
  29210. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29211. */
  29212. cullBackFaces: boolean;
  29213. /**
  29214. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29215. */
  29216. renderEvenInBackground: boolean;
  29217. /**
  29218. * Gets or sets a boolean indicating that cache can be kept between frames
  29219. */
  29220. preventCacheWipeBetweenFrames: boolean;
  29221. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29222. validateShaderPrograms: boolean;
  29223. /**
  29224. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29225. */
  29226. disableUniformBuffers: boolean;
  29227. /** @hidden */
  29228. _uniformBuffers: UniformBuffer[];
  29229. /**
  29230. * Gets a boolean indicating that the engine supports uniform buffers
  29231. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29232. */
  29233. readonly supportsUniformBuffers: boolean;
  29234. /** @hidden */
  29235. _gl: WebGLRenderingContext;
  29236. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29237. protected _windowIsBackground: boolean;
  29238. protected _webGLVersion: number;
  29239. protected _highPrecisionShadersAllowed: boolean;
  29240. /** @hidden */
  29241. readonly _shouldUseHighPrecisionShader: boolean;
  29242. /**
  29243. * Gets a boolean indicating that only power of 2 textures are supported
  29244. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29245. */
  29246. readonly needPOTTextures: boolean;
  29247. /** @hidden */
  29248. _badOS: boolean;
  29249. /** @hidden */
  29250. _badDesktopOS: boolean;
  29251. private _hardwareScalingLevel;
  29252. /** @hidden */
  29253. _caps: EngineCapabilities;
  29254. private _isStencilEnable;
  29255. protected _colorWrite: boolean;
  29256. private _glVersion;
  29257. private _glRenderer;
  29258. private _glVendor;
  29259. /** @hidden */
  29260. _videoTextureSupported: boolean;
  29261. protected _renderingQueueLaunched: boolean;
  29262. protected _activeRenderLoops: (() => void)[];
  29263. /**
  29264. * Observable signaled when a context lost event is raised
  29265. */
  29266. onContextLostObservable: Observable<ThinEngine>;
  29267. /**
  29268. * Observable signaled when a context restored event is raised
  29269. */
  29270. onContextRestoredObservable: Observable<ThinEngine>;
  29271. private _onContextLost;
  29272. private _onContextRestored;
  29273. protected _contextWasLost: boolean;
  29274. /** @hidden */
  29275. _doNotHandleContextLost: boolean;
  29276. /**
  29277. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29278. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29279. */
  29280. doNotHandleContextLost: boolean;
  29281. /**
  29282. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29283. */
  29284. disableVertexArrayObjects: boolean;
  29285. /** @hidden */
  29286. protected _depthCullingState: DepthCullingState;
  29287. /** @hidden */
  29288. protected _stencilState: StencilState;
  29289. /** @hidden */
  29290. protected _alphaState: AlphaState;
  29291. /** @hidden */
  29292. _internalTexturesCache: InternalTexture[];
  29293. /** @hidden */
  29294. protected _activeChannel: number;
  29295. private _currentTextureChannel;
  29296. /** @hidden */
  29297. protected _boundTexturesCache: {
  29298. [key: string]: Nullable<InternalTexture>;
  29299. };
  29300. /** @hidden */
  29301. protected _currentEffect: Nullable<Effect>;
  29302. /** @hidden */
  29303. protected _currentProgram: Nullable<WebGLProgram>;
  29304. private _compiledEffects;
  29305. private _vertexAttribArraysEnabled;
  29306. /** @hidden */
  29307. protected _cachedViewport: Nullable<IViewportLike>;
  29308. private _cachedVertexArrayObject;
  29309. /** @hidden */
  29310. protected _cachedVertexBuffers: any;
  29311. /** @hidden */
  29312. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29313. /** @hidden */
  29314. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29315. /** @hidden */
  29316. _currentRenderTarget: Nullable<InternalTexture>;
  29317. private _uintIndicesCurrentlySet;
  29318. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29319. /** @hidden */
  29320. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29321. private _currentBufferPointers;
  29322. private _currentInstanceLocations;
  29323. private _currentInstanceBuffers;
  29324. private _textureUnits;
  29325. /** @hidden */
  29326. _workingCanvas: Nullable<HTMLCanvasElement>;
  29327. /** @hidden */
  29328. _workingContext: Nullable<CanvasRenderingContext2D>;
  29329. /** @hidden */
  29330. _bindedRenderFunction: any;
  29331. private _vaoRecordInProgress;
  29332. private _mustWipeVertexAttributes;
  29333. private _emptyTexture;
  29334. private _emptyCubeTexture;
  29335. private _emptyTexture3D;
  29336. /** @hidden */
  29337. _frameHandler: number;
  29338. private _nextFreeTextureSlots;
  29339. private _maxSimultaneousTextures;
  29340. private _activeRequests;
  29341. protected _texturesSupported: string[];
  29342. /** @hidden */
  29343. _textureFormatInUse: Nullable<string>;
  29344. protected readonly _supportsHardwareTextureRescaling: boolean;
  29345. /**
  29346. * Gets the list of texture formats supported
  29347. */
  29348. readonly texturesSupported: Array<string>;
  29349. /**
  29350. * Gets the list of texture formats in use
  29351. */
  29352. readonly textureFormatInUse: Nullable<string>;
  29353. /**
  29354. * Gets the current viewport
  29355. */
  29356. readonly currentViewport: Nullable<IViewportLike>;
  29357. /**
  29358. * Gets the default empty texture
  29359. */
  29360. readonly emptyTexture: InternalTexture;
  29361. /**
  29362. * Gets the default empty 3D texture
  29363. */
  29364. readonly emptyTexture3D: InternalTexture;
  29365. /**
  29366. * Gets the default empty cube texture
  29367. */
  29368. readonly emptyCubeTexture: InternalTexture;
  29369. /**
  29370. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29371. */
  29372. readonly premultipliedAlpha: boolean;
  29373. /**
  29374. * Creates a new engine
  29375. * @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
  29376. * @param antialias defines enable antialiasing (default: false)
  29377. * @param options defines further options to be sent to the getContext() function
  29378. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29379. */
  29380. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29381. private _rebuildInternalTextures;
  29382. private _rebuildEffects;
  29383. /**
  29384. * Gets a boolean indicating if all created effects are ready
  29385. * @returns true if all effects are ready
  29386. */
  29387. areAllEffectsReady(): boolean;
  29388. protected _rebuildBuffers(): void;
  29389. private _initGLContext;
  29390. /**
  29391. * Gets version of the current webGL context
  29392. */
  29393. readonly webGLVersion: number;
  29394. /**
  29395. * Gets a string idenfifying the name of the class
  29396. * @returns "Engine" string
  29397. */
  29398. getClassName(): string;
  29399. /**
  29400. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29401. */
  29402. readonly isStencilEnable: boolean;
  29403. /** @hidden */
  29404. _prepareWorkingCanvas(): void;
  29405. /**
  29406. * Reset the texture cache to empty state
  29407. */
  29408. resetTextureCache(): void;
  29409. /**
  29410. * Gets an object containing information about the current webGL context
  29411. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29412. */
  29413. getGlInfo(): {
  29414. vendor: string;
  29415. renderer: string;
  29416. version: string;
  29417. };
  29418. /**
  29419. * Defines the hardware scaling level.
  29420. * By default the hardware scaling level is computed from the window device ratio.
  29421. * 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.
  29422. * @param level defines the level to use
  29423. */
  29424. setHardwareScalingLevel(level: number): void;
  29425. /**
  29426. * Gets the current hardware scaling level.
  29427. * By default the hardware scaling level is computed from the window device ratio.
  29428. * 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.
  29429. * @returns a number indicating the current hardware scaling level
  29430. */
  29431. getHardwareScalingLevel(): number;
  29432. /**
  29433. * Gets the list of loaded textures
  29434. * @returns an array containing all loaded textures
  29435. */
  29436. getLoadedTexturesCache(): InternalTexture[];
  29437. /**
  29438. * Gets the object containing all engine capabilities
  29439. * @returns the EngineCapabilities object
  29440. */
  29441. getCaps(): EngineCapabilities;
  29442. /**
  29443. * stop executing a render loop function and remove it from the execution array
  29444. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29445. */
  29446. stopRenderLoop(renderFunction?: () => void): void;
  29447. /** @hidden */
  29448. _renderLoop(): void;
  29449. /**
  29450. * Gets the HTML canvas attached with the current webGL context
  29451. * @returns a HTML canvas
  29452. */
  29453. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29454. /**
  29455. * Gets host window
  29456. * @returns the host window object
  29457. */
  29458. getHostWindow(): Window;
  29459. /**
  29460. * Gets the current render width
  29461. * @param useScreen defines if screen size must be used (or the current render target if any)
  29462. * @returns a number defining the current render width
  29463. */
  29464. getRenderWidth(useScreen?: boolean): number;
  29465. /**
  29466. * Gets the current render height
  29467. * @param useScreen defines if screen size must be used (or the current render target if any)
  29468. * @returns a number defining the current render height
  29469. */
  29470. getRenderHeight(useScreen?: boolean): number;
  29471. /**
  29472. * Can be used to override the current requestAnimationFrame requester.
  29473. * @hidden
  29474. */
  29475. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29476. /**
  29477. * Register and execute a render loop. The engine can have more than one render function
  29478. * @param renderFunction defines the function to continuously execute
  29479. */
  29480. runRenderLoop(renderFunction: () => void): void;
  29481. /**
  29482. * Clear the current render buffer or the current render target (if any is set up)
  29483. * @param color defines the color to use
  29484. * @param backBuffer defines if the back buffer must be cleared
  29485. * @param depth defines if the depth buffer must be cleared
  29486. * @param stencil defines if the stencil buffer must be cleared
  29487. */
  29488. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29489. private _viewportCached;
  29490. /** @hidden */
  29491. _viewport(x: number, y: number, width: number, height: number): void;
  29492. /**
  29493. * Set the WebGL's viewport
  29494. * @param viewport defines the viewport element to be used
  29495. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29496. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29497. */
  29498. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29499. /**
  29500. * Begin a new frame
  29501. */
  29502. beginFrame(): void;
  29503. /**
  29504. * Enf the current frame
  29505. */
  29506. endFrame(): void;
  29507. /**
  29508. * Resize the view according to the canvas' size
  29509. */
  29510. resize(): void;
  29511. /**
  29512. * Force a specific size of the canvas
  29513. * @param width defines the new canvas' width
  29514. * @param height defines the new canvas' height
  29515. */
  29516. setSize(width: number, height: number): void;
  29517. /**
  29518. * Binds the frame buffer to the specified texture.
  29519. * @param texture The texture to render to or null for the default canvas
  29520. * @param faceIndex The face of the texture to render to in case of cube texture
  29521. * @param requiredWidth The width of the target to render to
  29522. * @param requiredHeight The height of the target to render to
  29523. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29524. * @param depthStencilTexture The depth stencil texture to use to render
  29525. * @param lodLevel defines le lod level to bind to the frame buffer
  29526. */
  29527. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29528. /** @hidden */
  29529. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29530. /**
  29531. * Unbind the current render target texture from the webGL context
  29532. * @param texture defines the render target texture to unbind
  29533. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29534. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29535. */
  29536. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29537. /**
  29538. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29539. */
  29540. flushFramebuffer(): void;
  29541. /**
  29542. * Unbind the current render target and bind the default framebuffer
  29543. */
  29544. restoreDefaultFramebuffer(): void;
  29545. private _resetVertexBufferBinding;
  29546. /**
  29547. * Creates a vertex buffer
  29548. * @param data the data for the vertex buffer
  29549. * @returns the new WebGL static buffer
  29550. */
  29551. createVertexBuffer(data: DataArray): DataBuffer;
  29552. private _createVertexBuffer;
  29553. /**
  29554. * Creates a dynamic vertex buffer
  29555. * @param data the data for the dynamic vertex buffer
  29556. * @returns the new WebGL dynamic buffer
  29557. */
  29558. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29559. /**
  29560. * Updates a dynamic vertex buffer.
  29561. * @param vertexBuffer the vertex buffer to update
  29562. * @param data the data used to update the vertex buffer
  29563. * @param byteOffset the byte offset of the data
  29564. * @param byteLength the byte length of the data
  29565. */
  29566. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29567. protected _resetIndexBufferBinding(): void;
  29568. /**
  29569. * Creates a new index buffer
  29570. * @param indices defines the content of the index buffer
  29571. * @param updatable defines if the index buffer must be updatable
  29572. * @returns a new webGL buffer
  29573. */
  29574. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29575. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29576. /**
  29577. * Bind a webGL buffer to the webGL context
  29578. * @param buffer defines the buffer to bind
  29579. */
  29580. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29581. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  29582. private bindBuffer;
  29583. /**
  29584. * update the bound buffer with the given data
  29585. * @param data defines the data to update
  29586. */
  29587. updateArrayBuffer(data: Float32Array): void;
  29588. private _vertexAttribPointer;
  29589. private _bindIndexBufferWithCache;
  29590. private _bindVertexBuffersAttributes;
  29591. /**
  29592. * Records a vertex array object
  29593. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29594. * @param vertexBuffers defines the list of vertex buffers to store
  29595. * @param indexBuffer defines the index buffer to store
  29596. * @param effect defines the effect to store
  29597. * @returns the new vertex array object
  29598. */
  29599. recordVertexArrayObject(vertexBuffers: {
  29600. [key: string]: VertexBuffer;
  29601. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29602. /**
  29603. * Bind a specific vertex array object
  29604. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29605. * @param vertexArrayObject defines the vertex array object to bind
  29606. * @param indexBuffer defines the index buffer to bind
  29607. */
  29608. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29609. /**
  29610. * Bind webGl buffers directly to the webGL context
  29611. * @param vertexBuffer defines the vertex buffer to bind
  29612. * @param indexBuffer defines the index buffer to bind
  29613. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29614. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29615. * @param effect defines the effect associated with the vertex buffer
  29616. */
  29617. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29618. private _unbindVertexArrayObject;
  29619. /**
  29620. * Bind a list of vertex buffers to the webGL context
  29621. * @param vertexBuffers defines the list of vertex buffers to bind
  29622. * @param indexBuffer defines the index buffer to bind
  29623. * @param effect defines the effect associated with the vertex buffers
  29624. */
  29625. bindBuffers(vertexBuffers: {
  29626. [key: string]: Nullable<VertexBuffer>;
  29627. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29628. /**
  29629. * Unbind all instance attributes
  29630. */
  29631. unbindInstanceAttributes(): void;
  29632. /**
  29633. * Release and free the memory of a vertex array object
  29634. * @param vao defines the vertex array object to delete
  29635. */
  29636. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29637. /** @hidden */
  29638. _releaseBuffer(buffer: DataBuffer): boolean;
  29639. protected _deleteBuffer(buffer: DataBuffer): void;
  29640. /**
  29641. * Creates a webGL buffer to use with instanciation
  29642. * @param capacity defines the size of the buffer
  29643. * @returns the webGL buffer
  29644. */
  29645. createInstancesBuffer(capacity: number): DataBuffer;
  29646. /**
  29647. * Delete a webGL buffer used with instanciation
  29648. * @param buffer defines the webGL buffer to delete
  29649. */
  29650. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29651. /**
  29652. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29653. * @param instancesBuffer defines the webGL buffer to update and bind
  29654. * @param data defines the data to store in the buffer
  29655. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29656. */
  29657. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29658. /**
  29659. * Apply all cached states (depth, culling, stencil and alpha)
  29660. */
  29661. applyStates(): void;
  29662. /**
  29663. * Send a draw order
  29664. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29665. * @param indexStart defines the starting index
  29666. * @param indexCount defines the number of index to draw
  29667. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29668. */
  29669. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29670. /**
  29671. * Draw a list of points
  29672. * @param verticesStart defines the index of first vertex to draw
  29673. * @param verticesCount defines the count of vertices to draw
  29674. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29675. */
  29676. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29677. /**
  29678. * Draw a list of unindexed primitives
  29679. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29680. * @param verticesStart defines the index of first vertex to draw
  29681. * @param verticesCount defines the count of vertices to draw
  29682. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29683. */
  29684. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29685. /**
  29686. * Draw a list of indexed primitives
  29687. * @param fillMode defines the primitive to use
  29688. * @param indexStart defines the starting index
  29689. * @param indexCount defines the number of index to draw
  29690. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29691. */
  29692. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29693. /**
  29694. * Draw a list of unindexed primitives
  29695. * @param fillMode defines the primitive to use
  29696. * @param verticesStart defines the index of first vertex to draw
  29697. * @param verticesCount defines the count of vertices to draw
  29698. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29699. */
  29700. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29701. private _drawMode;
  29702. /** @hidden */
  29703. protected _reportDrawCall(): void;
  29704. /** @hidden */
  29705. _releaseEffect(effect: Effect): void;
  29706. /** @hidden */
  29707. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29708. /**
  29709. * Create a new effect (used to store vertex/fragment shaders)
  29710. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29711. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29712. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29713. * @param samplers defines an array of string used to represent textures
  29714. * @param defines defines the string containing the defines to use to compile the shaders
  29715. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29716. * @param onCompiled defines a function to call when the effect creation is successful
  29717. * @param onError defines a function to call when the effect creation has failed
  29718. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29719. * @returns the new Effect
  29720. */
  29721. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29722. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29723. private _compileShader;
  29724. private _compileRawShader;
  29725. /**
  29726. * Directly creates a webGL program
  29727. * @param pipelineContext defines the pipeline context to attach to
  29728. * @param vertexCode defines the vertex shader code to use
  29729. * @param fragmentCode defines the fragment shader code to use
  29730. * @param context defines the webGL context to use (if not set, the current one will be used)
  29731. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29732. * @returns the new webGL program
  29733. */
  29734. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29735. /**
  29736. * Creates a webGL program
  29737. * @param pipelineContext defines the pipeline context to attach to
  29738. * @param vertexCode defines the vertex shader code to use
  29739. * @param fragmentCode defines the fragment shader code to use
  29740. * @param defines defines the string containing the defines to use to compile the shaders
  29741. * @param context defines the webGL context to use (if not set, the current one will be used)
  29742. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29743. * @returns the new webGL program
  29744. */
  29745. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29746. /**
  29747. * Creates a new pipeline context
  29748. * @returns the new pipeline
  29749. */
  29750. createPipelineContext(): IPipelineContext;
  29751. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29752. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29753. /** @hidden */
  29754. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29755. /** @hidden */
  29756. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29757. /** @hidden */
  29758. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29759. /**
  29760. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29761. * @param pipelineContext defines the pipeline context to use
  29762. * @param uniformsNames defines the list of uniform names
  29763. * @returns an array of webGL uniform locations
  29764. */
  29765. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29766. /**
  29767. * Gets the lsit of active attributes for a given webGL program
  29768. * @param pipelineContext defines the pipeline context to use
  29769. * @param attributesNames defines the list of attribute names to get
  29770. * @returns an array of indices indicating the offset of each attribute
  29771. */
  29772. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29773. /**
  29774. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29775. * @param effect defines the effect to activate
  29776. */
  29777. enableEffect(effect: Nullable<Effect>): void;
  29778. /**
  29779. * Set the value of an uniform to an array of int32
  29780. * @param uniform defines the webGL uniform location where to store the value
  29781. * @param array defines the array of int32 to store
  29782. */
  29783. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29784. /**
  29785. * Set the value of an uniform to an array of int32 (stored as vec2)
  29786. * @param uniform defines the webGL uniform location where to store the value
  29787. * @param array defines the array of int32 to store
  29788. */
  29789. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29790. /**
  29791. * Set the value of an uniform to an array of int32 (stored as vec3)
  29792. * @param uniform defines the webGL uniform location where to store the value
  29793. * @param array defines the array of int32 to store
  29794. */
  29795. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29796. /**
  29797. * Set the value of an uniform to an array of int32 (stored as vec4)
  29798. * @param uniform defines the webGL uniform location where to store the value
  29799. * @param array defines the array of int32 to store
  29800. */
  29801. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29802. /**
  29803. * Set the value of an uniform to an array of float32
  29804. * @param uniform defines the webGL uniform location where to store the value
  29805. * @param array defines the array of float32 to store
  29806. */
  29807. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29808. /**
  29809. * Set the value of an uniform to an array of float32 (stored as vec2)
  29810. * @param uniform defines the webGL uniform location where to store the value
  29811. * @param array defines the array of float32 to store
  29812. */
  29813. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29814. /**
  29815. * Set the value of an uniform to an array of float32 (stored as vec3)
  29816. * @param uniform defines the webGL uniform location where to store the value
  29817. * @param array defines the array of float32 to store
  29818. */
  29819. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29820. /**
  29821. * Set the value of an uniform to an array of float32 (stored as vec4)
  29822. * @param uniform defines the webGL uniform location where to store the value
  29823. * @param array defines the array of float32 to store
  29824. */
  29825. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29826. /**
  29827. * Set the value of an uniform to an array of number
  29828. * @param uniform defines the webGL uniform location where to store the value
  29829. * @param array defines the array of number to store
  29830. */
  29831. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29832. /**
  29833. * Set the value of an uniform to an array of number (stored as vec2)
  29834. * @param uniform defines the webGL uniform location where to store the value
  29835. * @param array defines the array of number to store
  29836. */
  29837. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29838. /**
  29839. * Set the value of an uniform to an array of number (stored as vec3)
  29840. * @param uniform defines the webGL uniform location where to store the value
  29841. * @param array defines the array of number to store
  29842. */
  29843. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29844. /**
  29845. * Set the value of an uniform to an array of number (stored as vec4)
  29846. * @param uniform defines the webGL uniform location where to store the value
  29847. * @param array defines the array of number to store
  29848. */
  29849. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29850. /**
  29851. * Set the value of an uniform to an array of float32 (stored as matrices)
  29852. * @param uniform defines the webGL uniform location where to store the value
  29853. * @param matrices defines the array of float32 to store
  29854. */
  29855. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29856. /**
  29857. * Set the value of an uniform to a matrix (3x3)
  29858. * @param uniform defines the webGL uniform location where to store the value
  29859. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29860. */
  29861. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29862. /**
  29863. * Set the value of an uniform to a matrix (2x2)
  29864. * @param uniform defines the webGL uniform location where to store the value
  29865. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29866. */
  29867. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29868. /**
  29869. * Set the value of an uniform to a number (int)
  29870. * @param uniform defines the webGL uniform location where to store the value
  29871. * @param value defines the int number to store
  29872. */
  29873. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29874. /**
  29875. * Set the value of an uniform to a number (float)
  29876. * @param uniform defines the webGL uniform location where to store the value
  29877. * @param value defines the float number to store
  29878. */
  29879. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29880. /**
  29881. * Set the value of an uniform to a vec2
  29882. * @param uniform defines the webGL uniform location where to store the value
  29883. * @param x defines the 1st component of the value
  29884. * @param y defines the 2nd component of the value
  29885. */
  29886. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29887. /**
  29888. * Set the value of an uniform to a vec3
  29889. * @param uniform defines the webGL uniform location where to store the value
  29890. * @param x defines the 1st component of the value
  29891. * @param y defines the 2nd component of the value
  29892. * @param z defines the 3rd component of the value
  29893. */
  29894. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29895. /**
  29896. * Set the value of an uniform to a boolean
  29897. * @param uniform defines the webGL uniform location where to store the value
  29898. * @param bool defines the boolean to store
  29899. */
  29900. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29901. /**
  29902. * Set the value of an uniform to a vec4
  29903. * @param uniform defines the webGL uniform location where to store the value
  29904. * @param x defines the 1st component of the value
  29905. * @param y defines the 2nd component of the value
  29906. * @param z defines the 3rd component of the value
  29907. * @param w defines the 4th component of the value
  29908. */
  29909. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29910. /**
  29911. * Sets a Color4 on a uniform variable
  29912. * @param uniform defines the uniform location
  29913. * @param color4 defines the value to be set
  29914. */
  29915. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  29916. /**
  29917. * Gets the depth culling state manager
  29918. */
  29919. readonly depthCullingState: DepthCullingState;
  29920. /**
  29921. * Gets the alpha state manager
  29922. */
  29923. readonly alphaState: AlphaState;
  29924. /**
  29925. * Gets the stencil state manager
  29926. */
  29927. readonly stencilState: StencilState;
  29928. /**
  29929. * Clears the list of texture accessible through engine.
  29930. * This can help preventing texture load conflict due to name collision.
  29931. */
  29932. clearInternalTexturesCache(): void;
  29933. /**
  29934. * Force the entire cache to be cleared
  29935. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29936. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29937. */
  29938. wipeCaches(bruteForce?: boolean): void;
  29939. /** @hidden */
  29940. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29941. min: number;
  29942. mag: number;
  29943. };
  29944. /** @hidden */
  29945. _createTexture(): WebGLTexture;
  29946. /**
  29947. * Usually called from Texture.ts.
  29948. * Passed information to create a WebGLTexture
  29949. * @param urlArg defines a value which contains one of the following:
  29950. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29951. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29952. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29953. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29954. * @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)
  29955. * @param scene needed for loading to the correct scene
  29956. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29957. * @param onLoad optional callback to be called upon successful completion
  29958. * @param onError optional callback to be called upon failure
  29959. * @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
  29960. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29961. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29962. * @param forcedExtension defines the extension to use to pick the right loader
  29963. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29964. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29965. */
  29966. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29967. /**
  29968. * @hidden
  29969. */
  29970. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  29971. /**
  29972. * Creates a raw texture
  29973. * @param data defines the data to store in the texture
  29974. * @param width defines the width of the texture
  29975. * @param height defines the height of the texture
  29976. * @param format defines the format of the data
  29977. * @param generateMipMaps defines if the engine should generate the mip levels
  29978. * @param invertY defines if data must be stored with Y axis inverted
  29979. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29980. * @param compression defines the compression used (null by default)
  29981. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29982. * @returns the raw texture inside an InternalTexture
  29983. */
  29984. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29985. /**
  29986. * Creates a new raw cube texture
  29987. * @param data defines the array of data to use to create each face
  29988. * @param size defines the size of the textures
  29989. * @param format defines the format of the data
  29990. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29991. * @param generateMipMaps defines if the engine should generate the mip levels
  29992. * @param invertY defines if data must be stored with Y axis inverted
  29993. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29994. * @param compression defines the compression used (null by default)
  29995. * @returns the cube texture as an InternalTexture
  29996. */
  29997. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29998. /**
  29999. * Creates a new raw 3D texture
  30000. * @param data defines the data used to create the texture
  30001. * @param width defines the width of the texture
  30002. * @param height defines the height of the texture
  30003. * @param depth defines the depth of the texture
  30004. * @param format defines the format of the texture
  30005. * @param generateMipMaps defines if the engine must generate mip levels
  30006. * @param invertY defines if data must be stored with Y axis inverted
  30007. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30008. * @param compression defines the compressed used (can be null)
  30009. * @param textureType defines the compressed used (can be null)
  30010. * @returns a new raw 3D texture (stored in an InternalTexture)
  30011. */
  30012. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30013. private _unpackFlipYCached;
  30014. /**
  30015. * In case you are sharing the context with other applications, it might
  30016. * be interested to not cache the unpack flip y state to ensure a consistent
  30017. * value would be set.
  30018. */
  30019. enableUnpackFlipYCached: boolean;
  30020. /** @hidden */
  30021. _unpackFlipY(value: boolean): void;
  30022. /** @hidden */
  30023. _getUnpackAlignement(): number;
  30024. /**
  30025. * Update the sampling mode of a given texture
  30026. * @param samplingMode defines the required sampling mode
  30027. * @param texture defines the texture to update
  30028. */
  30029. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30030. /**
  30031. * Updates a depth texture Comparison Mode and Function.
  30032. * If the comparison Function is equal to 0, the mode will be set to none.
  30033. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30034. * @param texture The texture to set the comparison function for
  30035. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30036. */
  30037. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30038. /** @hidden */
  30039. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30040. width: number;
  30041. height: number;
  30042. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30043. /**
  30044. * Creates a depth stencil texture.
  30045. * This is only available in WebGL 2 or with the depth texture extension available.
  30046. * @param size The size of face edge in the texture.
  30047. * @param options The options defining the texture.
  30048. * @returns The texture
  30049. */
  30050. createDepthStencilTexture(size: number | {
  30051. width: number;
  30052. height: number;
  30053. }, options: DepthTextureCreationOptions): InternalTexture;
  30054. /**
  30055. * Creates a depth stencil texture.
  30056. * This is only available in WebGL 2 or with the depth texture extension available.
  30057. * @param size The size of face edge in the texture.
  30058. * @param options The options defining the texture.
  30059. * @returns The texture
  30060. */
  30061. private _createDepthStencilTexture;
  30062. /** @hidden */
  30063. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30064. /** @hidden */
  30065. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30066. /** @hidden */
  30067. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30068. /** @hidden */
  30069. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30070. /**
  30071. * @hidden
  30072. */
  30073. _setCubeMapTextureParams(loadMipmap: boolean): void;
  30074. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30075. private _prepareWebGLTexture;
  30076. /** @hidden */
  30077. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30078. /** @hidden */
  30079. _releaseFramebufferObjects(texture: InternalTexture): void;
  30080. /** @hidden */
  30081. _releaseTexture(texture: InternalTexture): void;
  30082. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30083. protected _setProgram(program: WebGLProgram): void;
  30084. protected _boundUniforms: {
  30085. [key: number]: WebGLUniformLocation;
  30086. };
  30087. /**
  30088. * Binds an effect to the webGL context
  30089. * @param effect defines the effect to bind
  30090. */
  30091. bindSamplers(effect: Effect): void;
  30092. private _activateCurrentTexture;
  30093. /** @hidden */
  30094. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30095. /** @hidden */
  30096. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30097. /**
  30098. * Unbind all textures from the webGL context
  30099. */
  30100. unbindAllTextures(): void;
  30101. /**
  30102. * Sets a texture to the according uniform.
  30103. * @param channel The texture channel
  30104. * @param uniform The uniform to set
  30105. * @param texture The texture to apply
  30106. */
  30107. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30108. private _bindSamplerUniformToChannel;
  30109. private _getTextureWrapMode;
  30110. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30111. /**
  30112. * Sets an array of texture to the webGL context
  30113. * @param channel defines the channel where the texture array must be set
  30114. * @param uniform defines the associated uniform location
  30115. * @param textures defines the array of textures to bind
  30116. */
  30117. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30118. /** @hidden */
  30119. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30120. private _setTextureParameterFloat;
  30121. private _setTextureParameterInteger;
  30122. /**
  30123. * Unbind all vertex attributes from the webGL context
  30124. */
  30125. unbindAllAttributes(): void;
  30126. /**
  30127. * 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
  30128. */
  30129. releaseEffects(): void;
  30130. /**
  30131. * Dispose and release all associated resources
  30132. */
  30133. dispose(): void;
  30134. /**
  30135. * Attach a new callback raised when context lost event is fired
  30136. * @param callback defines the callback to call
  30137. */
  30138. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30139. /**
  30140. * Attach a new callback raised when context restored event is fired
  30141. * @param callback defines the callback to call
  30142. */
  30143. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30144. /**
  30145. * Get the current error code of the webGL context
  30146. * @returns the error code
  30147. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30148. */
  30149. getError(): number;
  30150. private _canRenderToFloatFramebuffer;
  30151. private _canRenderToHalfFloatFramebuffer;
  30152. private _canRenderToFramebuffer;
  30153. /** @hidden */
  30154. _getWebGLTextureType(type: number): number;
  30155. /** @hidden */
  30156. _getInternalFormat(format: number): number;
  30157. /** @hidden */
  30158. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30159. /** @hidden */
  30160. _getRGBAMultiSampleBufferFormat(type: number): number;
  30161. /** @hidden */
  30162. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  30163. /**
  30164. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30165. * @returns true if the engine can be created
  30166. * @ignorenaming
  30167. */
  30168. static isSupported(): boolean;
  30169. /**
  30170. * Find the next highest power of two.
  30171. * @param x Number to start search from.
  30172. * @return Next highest power of two.
  30173. */
  30174. static CeilingPOT(x: number): number;
  30175. /**
  30176. * Find the next lowest power of two.
  30177. * @param x Number to start search from.
  30178. * @return Next lowest power of two.
  30179. */
  30180. static FloorPOT(x: number): number;
  30181. /**
  30182. * Find the nearest power of two.
  30183. * @param x Number to start search from.
  30184. * @return Next nearest power of two.
  30185. */
  30186. static NearestPOT(x: number): number;
  30187. /**
  30188. * Get the closest exponent of two
  30189. * @param value defines the value to approximate
  30190. * @param max defines the maximum value to return
  30191. * @param mode defines how to define the closest value
  30192. * @returns closest exponent of two of the given value
  30193. */
  30194. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30195. /**
  30196. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30197. * @param func - the function to be called
  30198. * @param requester - the object that will request the next frame. Falls back to window.
  30199. * @returns frame number
  30200. */
  30201. static QueueNewFrame(func: () => void, requester?: any): number;
  30202. }
  30203. }
  30204. declare module BABYLON {
  30205. /**
  30206. * Defines the source of the internal texture
  30207. */
  30208. export enum InternalTextureSource {
  30209. /**
  30210. * The source of the texture data is unknown
  30211. */
  30212. Unknown = 0,
  30213. /**
  30214. * Texture data comes from an URL
  30215. */
  30216. Url = 1,
  30217. /**
  30218. * Texture data is only used for temporary storage
  30219. */
  30220. Temp = 2,
  30221. /**
  30222. * Texture data comes from raw data (ArrayBuffer)
  30223. */
  30224. Raw = 3,
  30225. /**
  30226. * Texture content is dynamic (video or dynamic texture)
  30227. */
  30228. Dynamic = 4,
  30229. /**
  30230. * Texture content is generated by rendering to it
  30231. */
  30232. RenderTarget = 5,
  30233. /**
  30234. * Texture content is part of a multi render target process
  30235. */
  30236. MultiRenderTarget = 6,
  30237. /**
  30238. * Texture data comes from a cube data file
  30239. */
  30240. Cube = 7,
  30241. /**
  30242. * Texture data comes from a raw cube data
  30243. */
  30244. CubeRaw = 8,
  30245. /**
  30246. * Texture data come from a prefiltered cube data file
  30247. */
  30248. CubePrefiltered = 9,
  30249. /**
  30250. * Texture content is raw 3D data
  30251. */
  30252. Raw3D = 10,
  30253. /**
  30254. * Texture content is a depth texture
  30255. */
  30256. Depth = 11,
  30257. /**
  30258. * Texture data comes from a raw cube data encoded with RGBD
  30259. */
  30260. CubeRawRGBD = 12
  30261. }
  30262. /**
  30263. * Class used to store data associated with WebGL texture data for the engine
  30264. * This class should not be used directly
  30265. */
  30266. export class InternalTexture {
  30267. /** @hidden */
  30268. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  30269. /**
  30270. * Defines if the texture is ready
  30271. */
  30272. isReady: boolean;
  30273. /**
  30274. * Defines if the texture is a cube texture
  30275. */
  30276. isCube: boolean;
  30277. /**
  30278. * Defines if the texture contains 3D data
  30279. */
  30280. is3D: boolean;
  30281. /**
  30282. * Defines if the texture contains multiview data
  30283. */
  30284. isMultiview: boolean;
  30285. /**
  30286. * Gets the URL used to load this texture
  30287. */
  30288. url: string;
  30289. /**
  30290. * Gets the sampling mode of the texture
  30291. */
  30292. samplingMode: number;
  30293. /**
  30294. * Gets a boolean indicating if the texture needs mipmaps generation
  30295. */
  30296. generateMipMaps: boolean;
  30297. /**
  30298. * Gets the number of samples used by the texture (WebGL2+ only)
  30299. */
  30300. samples: number;
  30301. /**
  30302. * Gets the type of the texture (int, float...)
  30303. */
  30304. type: number;
  30305. /**
  30306. * Gets the format of the texture (RGB, RGBA...)
  30307. */
  30308. format: number;
  30309. /**
  30310. * Observable called when the texture is loaded
  30311. */
  30312. onLoadedObservable: Observable<InternalTexture>;
  30313. /**
  30314. * Gets the width of the texture
  30315. */
  30316. width: number;
  30317. /**
  30318. * Gets the height of the texture
  30319. */
  30320. height: number;
  30321. /**
  30322. * Gets the depth of the texture
  30323. */
  30324. depth: number;
  30325. /**
  30326. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  30327. */
  30328. baseWidth: number;
  30329. /**
  30330. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  30331. */
  30332. baseHeight: number;
  30333. /**
  30334. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  30335. */
  30336. baseDepth: number;
  30337. /**
  30338. * Gets a boolean indicating if the texture is inverted on Y axis
  30339. */
  30340. invertY: boolean;
  30341. /** @hidden */
  30342. _invertVScale: boolean;
  30343. /** @hidden */
  30344. _associatedChannel: number;
  30345. /** @hidden */
  30346. _source: InternalTextureSource;
  30347. /** @hidden */
  30348. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  30349. /** @hidden */
  30350. _bufferView: Nullable<ArrayBufferView>;
  30351. /** @hidden */
  30352. _bufferViewArray: Nullable<ArrayBufferView[]>;
  30353. /** @hidden */
  30354. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30355. /** @hidden */
  30356. _size: number;
  30357. /** @hidden */
  30358. _extension: string;
  30359. /** @hidden */
  30360. _files: Nullable<string[]>;
  30361. /** @hidden */
  30362. _workingCanvas: Nullable<HTMLCanvasElement>;
  30363. /** @hidden */
  30364. _workingContext: Nullable<CanvasRenderingContext2D>;
  30365. /** @hidden */
  30366. _framebuffer: Nullable<WebGLFramebuffer>;
  30367. /** @hidden */
  30368. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30369. /** @hidden */
  30370. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30371. /** @hidden */
  30372. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30373. /** @hidden */
  30374. _attachments: Nullable<number[]>;
  30375. /** @hidden */
  30376. _cachedCoordinatesMode: Nullable<number>;
  30377. /** @hidden */
  30378. _cachedWrapU: Nullable<number>;
  30379. /** @hidden */
  30380. _cachedWrapV: Nullable<number>;
  30381. /** @hidden */
  30382. _cachedWrapR: Nullable<number>;
  30383. /** @hidden */
  30384. _cachedAnisotropicFilteringLevel: Nullable<number>;
  30385. /** @hidden */
  30386. _isDisabled: boolean;
  30387. /** @hidden */
  30388. _compression: Nullable<string>;
  30389. /** @hidden */
  30390. _generateStencilBuffer: boolean;
  30391. /** @hidden */
  30392. _generateDepthBuffer: boolean;
  30393. /** @hidden */
  30394. _comparisonFunction: number;
  30395. /** @hidden */
  30396. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30397. /** @hidden */
  30398. _lodGenerationScale: number;
  30399. /** @hidden */
  30400. _lodGenerationOffset: number;
  30401. /** @hidden */
  30402. _colorTextureArray: Nullable<WebGLTexture>;
  30403. /** @hidden */
  30404. _depthStencilTextureArray: Nullable<WebGLTexture>;
  30405. /** @hidden */
  30406. _lodTextureHigh: Nullable<BaseTexture>;
  30407. /** @hidden */
  30408. _lodTextureMid: Nullable<BaseTexture>;
  30409. /** @hidden */
  30410. _lodTextureLow: Nullable<BaseTexture>;
  30411. /** @hidden */
  30412. _isRGBD: boolean;
  30413. /** @hidden */
  30414. _linearSpecularLOD: boolean;
  30415. /** @hidden */
  30416. _irradianceTexture: Nullable<BaseTexture>;
  30417. /** @hidden */
  30418. _webGLTexture: Nullable<WebGLTexture>;
  30419. /** @hidden */
  30420. _references: number;
  30421. private _engine;
  30422. /**
  30423. * Gets the Engine the texture belongs to.
  30424. * @returns The babylon engine
  30425. */
  30426. getEngine(): ThinEngine;
  30427. /**
  30428. * Gets the data source type of the texture
  30429. */
  30430. readonly source: InternalTextureSource;
  30431. /**
  30432. * Creates a new InternalTexture
  30433. * @param engine defines the engine to use
  30434. * @param source defines the type of data that will be used
  30435. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30436. */
  30437. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  30438. /**
  30439. * Increments the number of references (ie. the number of Texture that point to it)
  30440. */
  30441. incrementReferences(): void;
  30442. /**
  30443. * Change the size of the texture (not the size of the content)
  30444. * @param width defines the new width
  30445. * @param height defines the new height
  30446. * @param depth defines the new depth (1 by default)
  30447. */
  30448. updateSize(width: int, height: int, depth?: int): void;
  30449. /** @hidden */
  30450. _rebuild(): void;
  30451. /** @hidden */
  30452. _swapAndDie(target: InternalTexture): void;
  30453. /**
  30454. * Dispose the current allocated resources
  30455. */
  30456. dispose(): void;
  30457. }
  30458. }
  30459. declare module BABYLON {
  30460. /**
  30461. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30463. */
  30464. export class Analyser {
  30465. /**
  30466. * Gets or sets the smoothing
  30467. * @ignorenaming
  30468. */
  30469. SMOOTHING: number;
  30470. /**
  30471. * Gets or sets the FFT table size
  30472. * @ignorenaming
  30473. */
  30474. FFT_SIZE: number;
  30475. /**
  30476. * Gets or sets the bar graph amplitude
  30477. * @ignorenaming
  30478. */
  30479. BARGRAPHAMPLITUDE: number;
  30480. /**
  30481. * Gets or sets the position of the debug canvas
  30482. * @ignorenaming
  30483. */
  30484. DEBUGCANVASPOS: {
  30485. x: number;
  30486. y: number;
  30487. };
  30488. /**
  30489. * Gets or sets the debug canvas size
  30490. * @ignorenaming
  30491. */
  30492. DEBUGCANVASSIZE: {
  30493. width: number;
  30494. height: number;
  30495. };
  30496. private _byteFreqs;
  30497. private _byteTime;
  30498. private _floatFreqs;
  30499. private _webAudioAnalyser;
  30500. private _debugCanvas;
  30501. private _debugCanvasContext;
  30502. private _scene;
  30503. private _registerFunc;
  30504. private _audioEngine;
  30505. /**
  30506. * Creates a new analyser
  30507. * @param scene defines hosting scene
  30508. */
  30509. constructor(scene: Scene);
  30510. /**
  30511. * Get the number of data values you will have to play with for the visualization
  30512. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30513. * @returns a number
  30514. */
  30515. getFrequencyBinCount(): number;
  30516. /**
  30517. * Gets the current frequency data as a byte array
  30518. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30519. * @returns a Uint8Array
  30520. */
  30521. getByteFrequencyData(): Uint8Array;
  30522. /**
  30523. * Gets the current waveform as a byte array
  30524. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30525. * @returns a Uint8Array
  30526. */
  30527. getByteTimeDomainData(): Uint8Array;
  30528. /**
  30529. * Gets the current frequency data as a float array
  30530. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30531. * @returns a Float32Array
  30532. */
  30533. getFloatFrequencyData(): Float32Array;
  30534. /**
  30535. * Renders the debug canvas
  30536. */
  30537. drawDebugCanvas(): void;
  30538. /**
  30539. * Stops rendering the debug canvas and removes it
  30540. */
  30541. stopDebugCanvas(): void;
  30542. /**
  30543. * Connects two audio nodes
  30544. * @param inputAudioNode defines first node to connect
  30545. * @param outputAudioNode defines second node to connect
  30546. */
  30547. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30548. /**
  30549. * Releases all associated resources
  30550. */
  30551. dispose(): void;
  30552. }
  30553. }
  30554. declare module BABYLON {
  30555. /**
  30556. * This represents an audio engine and it is responsible
  30557. * to play, synchronize and analyse sounds throughout the application.
  30558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30559. */
  30560. export interface IAudioEngine extends IDisposable {
  30561. /**
  30562. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30563. */
  30564. readonly canUseWebAudio: boolean;
  30565. /**
  30566. * Gets the current AudioContext if available.
  30567. */
  30568. readonly audioContext: Nullable<AudioContext>;
  30569. /**
  30570. * The master gain node defines the global audio volume of your audio engine.
  30571. */
  30572. readonly masterGain: GainNode;
  30573. /**
  30574. * Gets whether or not mp3 are supported by your browser.
  30575. */
  30576. readonly isMP3supported: boolean;
  30577. /**
  30578. * Gets whether or not ogg are supported by your browser.
  30579. */
  30580. readonly isOGGsupported: boolean;
  30581. /**
  30582. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30583. * @ignoreNaming
  30584. */
  30585. WarnedWebAudioUnsupported: boolean;
  30586. /**
  30587. * Defines if the audio engine relies on a custom unlocked button.
  30588. * In this case, the embedded button will not be displayed.
  30589. */
  30590. useCustomUnlockedButton: boolean;
  30591. /**
  30592. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30593. */
  30594. readonly unlocked: boolean;
  30595. /**
  30596. * Event raised when audio has been unlocked on the browser.
  30597. */
  30598. onAudioUnlockedObservable: Observable<AudioEngine>;
  30599. /**
  30600. * Event raised when audio has been locked on the browser.
  30601. */
  30602. onAudioLockedObservable: Observable<AudioEngine>;
  30603. /**
  30604. * Flags the audio engine in Locked state.
  30605. * This happens due to new browser policies preventing audio to autoplay.
  30606. */
  30607. lock(): void;
  30608. /**
  30609. * Unlocks the audio engine once a user action has been done on the dom.
  30610. * This is helpful to resume play once browser policies have been satisfied.
  30611. */
  30612. unlock(): void;
  30613. }
  30614. /**
  30615. * This represents the default audio engine used in babylon.
  30616. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30617. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30618. */
  30619. export class AudioEngine implements IAudioEngine {
  30620. private _audioContext;
  30621. private _audioContextInitialized;
  30622. private _muteButton;
  30623. private _hostElement;
  30624. /**
  30625. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30626. */
  30627. canUseWebAudio: boolean;
  30628. /**
  30629. * The master gain node defines the global audio volume of your audio engine.
  30630. */
  30631. masterGain: GainNode;
  30632. /**
  30633. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30634. * @ignoreNaming
  30635. */
  30636. WarnedWebAudioUnsupported: boolean;
  30637. /**
  30638. * Gets whether or not mp3 are supported by your browser.
  30639. */
  30640. isMP3supported: boolean;
  30641. /**
  30642. * Gets whether or not ogg are supported by your browser.
  30643. */
  30644. isOGGsupported: boolean;
  30645. /**
  30646. * Gets whether audio has been unlocked on the device.
  30647. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30648. * a user interaction has happened.
  30649. */
  30650. unlocked: boolean;
  30651. /**
  30652. * Defines if the audio engine relies on a custom unlocked button.
  30653. * In this case, the embedded button will not be displayed.
  30654. */
  30655. useCustomUnlockedButton: boolean;
  30656. /**
  30657. * Event raised when audio has been unlocked on the browser.
  30658. */
  30659. onAudioUnlockedObservable: Observable<AudioEngine>;
  30660. /**
  30661. * Event raised when audio has been locked on the browser.
  30662. */
  30663. onAudioLockedObservable: Observable<AudioEngine>;
  30664. /**
  30665. * Gets the current AudioContext if available.
  30666. */
  30667. readonly audioContext: Nullable<AudioContext>;
  30668. private _connectedAnalyser;
  30669. /**
  30670. * Instantiates a new audio engine.
  30671. *
  30672. * There should be only one per page as some browsers restrict the number
  30673. * of audio contexts you can create.
  30674. * @param hostElement defines the host element where to display the mute icon if necessary
  30675. */
  30676. constructor(hostElement?: Nullable<HTMLElement>);
  30677. /**
  30678. * Flags the audio engine in Locked state.
  30679. * This happens due to new browser policies preventing audio to autoplay.
  30680. */
  30681. lock(): void;
  30682. /**
  30683. * Unlocks the audio engine once a user action has been done on the dom.
  30684. * This is helpful to resume play once browser policies have been satisfied.
  30685. */
  30686. unlock(): void;
  30687. private _resumeAudioContext;
  30688. private _initializeAudioContext;
  30689. private _tryToRun;
  30690. private _triggerRunningState;
  30691. private _triggerSuspendedState;
  30692. private _displayMuteButton;
  30693. private _moveButtonToTopLeft;
  30694. private _onResize;
  30695. private _hideMuteButton;
  30696. /**
  30697. * Destroy and release the resources associated with the audio ccontext.
  30698. */
  30699. dispose(): void;
  30700. /**
  30701. * Gets the global volume sets on the master gain.
  30702. * @returns the global volume if set or -1 otherwise
  30703. */
  30704. getGlobalVolume(): number;
  30705. /**
  30706. * Sets the global volume of your experience (sets on the master gain).
  30707. * @param newVolume Defines the new global volume of the application
  30708. */
  30709. setGlobalVolume(newVolume: number): void;
  30710. /**
  30711. * Connect the audio engine to an audio analyser allowing some amazing
  30712. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30714. * @param analyser The analyser to connect to the engine
  30715. */
  30716. connectToAnalyser(analyser: Analyser): void;
  30717. }
  30718. }
  30719. declare module BABYLON {
  30720. /**
  30721. * Interface used to present a loading screen while loading a scene
  30722. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30723. */
  30724. export interface ILoadingScreen {
  30725. /**
  30726. * Function called to display the loading screen
  30727. */
  30728. displayLoadingUI: () => void;
  30729. /**
  30730. * Function called to hide the loading screen
  30731. */
  30732. hideLoadingUI: () => void;
  30733. /**
  30734. * Gets or sets the color to use for the background
  30735. */
  30736. loadingUIBackgroundColor: string;
  30737. /**
  30738. * Gets or sets the text to display while loading
  30739. */
  30740. loadingUIText: string;
  30741. }
  30742. /**
  30743. * Class used for the default loading screen
  30744. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30745. */
  30746. export class DefaultLoadingScreen implements ILoadingScreen {
  30747. private _renderingCanvas;
  30748. private _loadingText;
  30749. private _loadingDivBackgroundColor;
  30750. private _loadingDiv;
  30751. private _loadingTextDiv;
  30752. /** Gets or sets the logo url to use for the default loading screen */
  30753. static DefaultLogoUrl: string;
  30754. /** Gets or sets the spinner url to use for the default loading screen */
  30755. static DefaultSpinnerUrl: string;
  30756. /**
  30757. * Creates a new default loading screen
  30758. * @param _renderingCanvas defines the canvas used to render the scene
  30759. * @param _loadingText defines the default text to display
  30760. * @param _loadingDivBackgroundColor defines the default background color
  30761. */
  30762. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30763. /**
  30764. * Function called to display the loading screen
  30765. */
  30766. displayLoadingUI(): void;
  30767. /**
  30768. * Function called to hide the loading screen
  30769. */
  30770. hideLoadingUI(): void;
  30771. /**
  30772. * Gets or sets the text to display while loading
  30773. */
  30774. loadingUIText: string;
  30775. /**
  30776. * Gets or sets the color to use for the background
  30777. */
  30778. loadingUIBackgroundColor: string;
  30779. private _resizeLoadingUI;
  30780. }
  30781. }
  30782. declare module BABYLON {
  30783. /**
  30784. * Interface for any object that can request an animation frame
  30785. */
  30786. export interface ICustomAnimationFrameRequester {
  30787. /**
  30788. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30789. */
  30790. renderFunction?: Function;
  30791. /**
  30792. * Called to request the next frame to render to
  30793. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30794. */
  30795. requestAnimationFrame: Function;
  30796. /**
  30797. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30798. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30799. */
  30800. requestID?: number;
  30801. }
  30802. }
  30803. declare module BABYLON {
  30804. /**
  30805. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30806. */
  30807. export class PerformanceMonitor {
  30808. private _enabled;
  30809. private _rollingFrameTime;
  30810. private _lastFrameTimeMs;
  30811. /**
  30812. * constructor
  30813. * @param frameSampleSize The number of samples required to saturate the sliding window
  30814. */
  30815. constructor(frameSampleSize?: number);
  30816. /**
  30817. * Samples current frame
  30818. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30819. */
  30820. sampleFrame(timeMs?: number): void;
  30821. /**
  30822. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30823. */
  30824. readonly averageFrameTime: number;
  30825. /**
  30826. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30827. */
  30828. readonly averageFrameTimeVariance: number;
  30829. /**
  30830. * Returns the frame time of the most recent frame
  30831. */
  30832. readonly instantaneousFrameTime: number;
  30833. /**
  30834. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30835. */
  30836. readonly averageFPS: number;
  30837. /**
  30838. * Returns the average framerate in frames per second using the most recent frame time
  30839. */
  30840. readonly instantaneousFPS: number;
  30841. /**
  30842. * Returns true if enough samples have been taken to completely fill the sliding window
  30843. */
  30844. readonly isSaturated: boolean;
  30845. /**
  30846. * Enables contributions to the sliding window sample set
  30847. */
  30848. enable(): void;
  30849. /**
  30850. * Disables contributions to the sliding window sample set
  30851. * Samples will not be interpolated over the disabled period
  30852. */
  30853. disable(): void;
  30854. /**
  30855. * Returns true if sampling is enabled
  30856. */
  30857. readonly isEnabled: boolean;
  30858. /**
  30859. * Resets performance monitor
  30860. */
  30861. reset(): void;
  30862. }
  30863. /**
  30864. * RollingAverage
  30865. *
  30866. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30867. */
  30868. export class RollingAverage {
  30869. /**
  30870. * Current average
  30871. */
  30872. average: number;
  30873. /**
  30874. * Current variance
  30875. */
  30876. variance: number;
  30877. protected _samples: Array<number>;
  30878. protected _sampleCount: number;
  30879. protected _pos: number;
  30880. protected _m2: number;
  30881. /**
  30882. * constructor
  30883. * @param length The number of samples required to saturate the sliding window
  30884. */
  30885. constructor(length: number);
  30886. /**
  30887. * Adds a sample to the sample set
  30888. * @param v The sample value
  30889. */
  30890. add(v: number): void;
  30891. /**
  30892. * Returns previously added values or null if outside of history or outside the sliding window domain
  30893. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30894. * @return Value previously recorded with add() or null if outside of range
  30895. */
  30896. history(i: number): number;
  30897. /**
  30898. * Returns true if enough samples have been taken to completely fill the sliding window
  30899. * @return true if sample-set saturated
  30900. */
  30901. isSaturated(): boolean;
  30902. /**
  30903. * Resets the rolling average (equivalent to 0 samples taken so far)
  30904. */
  30905. reset(): void;
  30906. /**
  30907. * Wraps a value around the sample range boundaries
  30908. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30909. * @return Wrapped position in sample range
  30910. */
  30911. protected _wrapPosition(i: number): number;
  30912. }
  30913. }
  30914. declare module BABYLON {
  30915. /**
  30916. * This class is used to track a performance counter which is number based.
  30917. * The user has access to many properties which give statistics of different nature.
  30918. *
  30919. * The implementer can track two kinds of Performance Counter: time and count.
  30920. * 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.
  30921. * 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.
  30922. */
  30923. export class PerfCounter {
  30924. /**
  30925. * Gets or sets a global boolean to turn on and off all the counters
  30926. */
  30927. static Enabled: boolean;
  30928. /**
  30929. * Returns the smallest value ever
  30930. */
  30931. readonly min: number;
  30932. /**
  30933. * Returns the biggest value ever
  30934. */
  30935. readonly max: number;
  30936. /**
  30937. * Returns the average value since the performance counter is running
  30938. */
  30939. readonly average: number;
  30940. /**
  30941. * Returns the average value of the last second the counter was monitored
  30942. */
  30943. readonly lastSecAverage: number;
  30944. /**
  30945. * Returns the current value
  30946. */
  30947. readonly current: number;
  30948. /**
  30949. * Gets the accumulated total
  30950. */
  30951. readonly total: number;
  30952. /**
  30953. * Gets the total value count
  30954. */
  30955. readonly count: number;
  30956. /**
  30957. * Creates a new counter
  30958. */
  30959. constructor();
  30960. /**
  30961. * Call this method to start monitoring a new frame.
  30962. * 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.
  30963. */
  30964. fetchNewFrame(): void;
  30965. /**
  30966. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30967. * @param newCount the count value to add to the monitored count
  30968. * @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.
  30969. */
  30970. addCount(newCount: number, fetchResult: boolean): void;
  30971. /**
  30972. * Start monitoring this performance counter
  30973. */
  30974. beginMonitoring(): void;
  30975. /**
  30976. * Compute the time lapsed since the previous beginMonitoring() call.
  30977. * @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
  30978. */
  30979. endMonitoring(newFrame?: boolean): void;
  30980. private _fetchResult;
  30981. private _startMonitoringTime;
  30982. private _min;
  30983. private _max;
  30984. private _average;
  30985. private _current;
  30986. private _totalValueCount;
  30987. private _totalAccumulated;
  30988. private _lastSecAverage;
  30989. private _lastSecAccumulated;
  30990. private _lastSecTime;
  30991. private _lastSecValueCount;
  30992. }
  30993. }
  30994. declare module BABYLON {
  30995. /**
  30996. * Defines the interface used by display changed events
  30997. */
  30998. export interface IDisplayChangedEventArgs {
  30999. /** Gets the vrDisplay object (if any) */
  31000. vrDisplay: Nullable<any>;
  31001. /** Gets a boolean indicating if webVR is supported */
  31002. vrSupported: boolean;
  31003. }
  31004. /**
  31005. * Defines the interface used by objects containing a viewport (like a camera)
  31006. */
  31007. interface IViewportOwnerLike {
  31008. /**
  31009. * Gets or sets the viewport
  31010. */
  31011. viewport: IViewportLike;
  31012. }
  31013. /**
  31014. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31015. */
  31016. export class Engine extends ThinEngine {
  31017. /** Defines that alpha blending is disabled */
  31018. static readonly ALPHA_DISABLE: number;
  31019. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31020. static readonly ALPHA_ADD: number;
  31021. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31022. static readonly ALPHA_COMBINE: number;
  31023. /** Defines that alpha blending to DEST - SRC * DEST */
  31024. static readonly ALPHA_SUBTRACT: number;
  31025. /** Defines that alpha blending to SRC * DEST */
  31026. static readonly ALPHA_MULTIPLY: number;
  31027. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31028. static readonly ALPHA_MAXIMIZED: number;
  31029. /** Defines that alpha blending to SRC + DEST */
  31030. static readonly ALPHA_ONEONE: number;
  31031. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31032. static readonly ALPHA_PREMULTIPLIED: number;
  31033. /**
  31034. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31035. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31036. */
  31037. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31038. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31039. static readonly ALPHA_INTERPOLATE: number;
  31040. /**
  31041. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31042. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31043. */
  31044. static readonly ALPHA_SCREENMODE: number;
  31045. /** Defines that the ressource is not delayed*/
  31046. static readonly DELAYLOADSTATE_NONE: number;
  31047. /** Defines that the ressource was successfully delay loaded */
  31048. static readonly DELAYLOADSTATE_LOADED: number;
  31049. /** Defines that the ressource is currently delay loading */
  31050. static readonly DELAYLOADSTATE_LOADING: number;
  31051. /** Defines that the ressource is delayed and has not started loading */
  31052. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31053. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31054. static readonly NEVER: number;
  31055. /** 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 */
  31056. static readonly ALWAYS: number;
  31057. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31058. static readonly LESS: number;
  31059. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31060. static readonly EQUAL: number;
  31061. /** 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 */
  31062. static readonly LEQUAL: number;
  31063. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31064. static readonly GREATER: number;
  31065. /** 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 */
  31066. static readonly GEQUAL: number;
  31067. /** 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 */
  31068. static readonly NOTEQUAL: number;
  31069. /** Passed to stencilOperation to specify that stencil value must be kept */
  31070. static readonly KEEP: number;
  31071. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31072. static readonly REPLACE: number;
  31073. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31074. static readonly INCR: number;
  31075. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31076. static readonly DECR: number;
  31077. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31078. static readonly INVERT: number;
  31079. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31080. static readonly INCR_WRAP: number;
  31081. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31082. static readonly DECR_WRAP: number;
  31083. /** Texture is not repeating outside of 0..1 UVs */
  31084. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31085. /** Texture is repeating outside of 0..1 UVs */
  31086. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31087. /** Texture is repeating and mirrored */
  31088. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31089. /** ALPHA */
  31090. static readonly TEXTUREFORMAT_ALPHA: number;
  31091. /** LUMINANCE */
  31092. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31093. /** LUMINANCE_ALPHA */
  31094. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31095. /** RGB */
  31096. static readonly TEXTUREFORMAT_RGB: number;
  31097. /** RGBA */
  31098. static readonly TEXTUREFORMAT_RGBA: number;
  31099. /** RED */
  31100. static readonly TEXTUREFORMAT_RED: number;
  31101. /** RED (2nd reference) */
  31102. static readonly TEXTUREFORMAT_R: number;
  31103. /** RG */
  31104. static readonly TEXTUREFORMAT_RG: number;
  31105. /** RED_INTEGER */
  31106. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31107. /** RED_INTEGER (2nd reference) */
  31108. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31109. /** RG_INTEGER */
  31110. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31111. /** RGB_INTEGER */
  31112. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31113. /** RGBA_INTEGER */
  31114. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31115. /** UNSIGNED_BYTE */
  31116. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31117. /** UNSIGNED_BYTE (2nd reference) */
  31118. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31119. /** FLOAT */
  31120. static readonly TEXTURETYPE_FLOAT: number;
  31121. /** HALF_FLOAT */
  31122. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31123. /** BYTE */
  31124. static readonly TEXTURETYPE_BYTE: number;
  31125. /** SHORT */
  31126. static readonly TEXTURETYPE_SHORT: number;
  31127. /** UNSIGNED_SHORT */
  31128. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31129. /** INT */
  31130. static readonly TEXTURETYPE_INT: number;
  31131. /** UNSIGNED_INT */
  31132. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31133. /** UNSIGNED_SHORT_4_4_4_4 */
  31134. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31135. /** UNSIGNED_SHORT_5_5_5_1 */
  31136. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31137. /** UNSIGNED_SHORT_5_6_5 */
  31138. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31139. /** UNSIGNED_INT_2_10_10_10_REV */
  31140. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31141. /** UNSIGNED_INT_24_8 */
  31142. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31143. /** UNSIGNED_INT_10F_11F_11F_REV */
  31144. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31145. /** UNSIGNED_INT_5_9_9_9_REV */
  31146. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31147. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31148. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31149. /** nearest is mag = nearest and min = nearest and mip = linear */
  31150. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31151. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31152. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31153. /** Trilinear is mag = linear and min = linear and mip = linear */
  31154. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31155. /** nearest is mag = nearest and min = nearest and mip = linear */
  31156. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31157. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31158. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31159. /** Trilinear is mag = linear and min = linear and mip = linear */
  31160. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31161. /** mag = nearest and min = nearest and mip = nearest */
  31162. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31163. /** mag = nearest and min = linear and mip = nearest */
  31164. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31165. /** mag = nearest and min = linear and mip = linear */
  31166. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31167. /** mag = nearest and min = linear and mip = none */
  31168. static readonly TEXTURE_NEAREST_LINEAR: number;
  31169. /** mag = nearest and min = nearest and mip = none */
  31170. static readonly TEXTURE_NEAREST_NEAREST: number;
  31171. /** mag = linear and min = nearest and mip = nearest */
  31172. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31173. /** mag = linear and min = nearest and mip = linear */
  31174. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31175. /** mag = linear and min = linear and mip = none */
  31176. static readonly TEXTURE_LINEAR_LINEAR: number;
  31177. /** mag = linear and min = nearest and mip = none */
  31178. static readonly TEXTURE_LINEAR_NEAREST: number;
  31179. /** Explicit coordinates mode */
  31180. static readonly TEXTURE_EXPLICIT_MODE: number;
  31181. /** Spherical coordinates mode */
  31182. static readonly TEXTURE_SPHERICAL_MODE: number;
  31183. /** Planar coordinates mode */
  31184. static readonly TEXTURE_PLANAR_MODE: number;
  31185. /** Cubic coordinates mode */
  31186. static readonly TEXTURE_CUBIC_MODE: number;
  31187. /** Projection coordinates mode */
  31188. static readonly TEXTURE_PROJECTION_MODE: number;
  31189. /** Skybox coordinates mode */
  31190. static readonly TEXTURE_SKYBOX_MODE: number;
  31191. /** Inverse Cubic coordinates mode */
  31192. static readonly TEXTURE_INVCUBIC_MODE: number;
  31193. /** Equirectangular coordinates mode */
  31194. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  31195. /** Equirectangular Fixed coordinates mode */
  31196. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  31197. /** Equirectangular Fixed Mirrored coordinates mode */
  31198. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  31199. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  31200. static readonly SCALEMODE_FLOOR: number;
  31201. /** Defines that texture rescaling will look for the nearest power of 2 size */
  31202. static readonly SCALEMODE_NEAREST: number;
  31203. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  31204. static readonly SCALEMODE_CEILING: number;
  31205. /**
  31206. * Returns the current npm package of the sdk
  31207. */
  31208. static readonly NpmPackage: string;
  31209. /**
  31210. * Returns the current version of the framework
  31211. */
  31212. static readonly Version: string;
  31213. /** Gets the list of created engines */
  31214. static readonly Instances: Engine[];
  31215. /**
  31216. * Gets the latest created engine
  31217. */
  31218. static readonly LastCreatedEngine: Nullable<Engine>;
  31219. /**
  31220. * Gets the latest created scene
  31221. */
  31222. static readonly LastCreatedScene: Nullable<Scene>;
  31223. /**
  31224. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  31225. * @param flag defines which part of the materials must be marked as dirty
  31226. * @param predicate defines a predicate used to filter which materials should be affected
  31227. */
  31228. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  31229. /**
  31230. * Method called to create the default loading screen.
  31231. * This can be overriden in your own app.
  31232. * @param canvas The rendering canvas element
  31233. * @returns The loading screen
  31234. */
  31235. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31236. /**
  31237. * Method called to create the default rescale post process on each engine.
  31238. */
  31239. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31240. /**
  31241. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31242. **/
  31243. enableOfflineSupport: boolean;
  31244. /**
  31245. * 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)
  31246. **/
  31247. disableManifestCheck: boolean;
  31248. /**
  31249. * Gets the list of created scenes
  31250. */
  31251. scenes: Scene[];
  31252. /**
  31253. * Event raised when a new scene is created
  31254. */
  31255. onNewSceneAddedObservable: Observable<Scene>;
  31256. /**
  31257. * Gets the list of created postprocesses
  31258. */
  31259. postProcesses: PostProcess[];
  31260. /**
  31261. * Gets a boolean indicating if the pointer is currently locked
  31262. */
  31263. isPointerLock: boolean;
  31264. /**
  31265. * Observable event triggered each time the rendering canvas is resized
  31266. */
  31267. onResizeObservable: Observable<Engine>;
  31268. /**
  31269. * Observable event triggered each time the canvas loses focus
  31270. */
  31271. onCanvasBlurObservable: Observable<Engine>;
  31272. /**
  31273. * Observable event triggered each time the canvas gains focus
  31274. */
  31275. onCanvasFocusObservable: Observable<Engine>;
  31276. /**
  31277. * Observable event triggered each time the canvas receives pointerout event
  31278. */
  31279. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31280. /**
  31281. * Observable event triggered before each texture is initialized
  31282. */
  31283. onBeforeTextureInitObservable: Observable<Texture>;
  31284. /**
  31285. * Observable raised when the engine begins a new frame
  31286. */
  31287. onBeginFrameObservable: Observable<Engine>;
  31288. /**
  31289. * If set, will be used to request the next animation frame for the render loop
  31290. */
  31291. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31292. /**
  31293. * Observable raised when the engine ends the current frame
  31294. */
  31295. onEndFrameObservable: Observable<Engine>;
  31296. /**
  31297. * Observable raised when the engine is about to compile a shader
  31298. */
  31299. onBeforeShaderCompilationObservable: Observable<Engine>;
  31300. /**
  31301. * Observable raised when the engine has jsut compiled a shader
  31302. */
  31303. onAfterShaderCompilationObservable: Observable<Engine>;
  31304. /**
  31305. * Gets the audio engine
  31306. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31307. * @ignorenaming
  31308. */
  31309. static audioEngine: IAudioEngine;
  31310. /**
  31311. * Default AudioEngine factory responsible of creating the Audio Engine.
  31312. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31313. */
  31314. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31315. /**
  31316. * Default offline support factory responsible of creating a tool used to store data locally.
  31317. * By default, this will create a Database object if the workload has been embedded.
  31318. */
  31319. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31320. private _loadingScreen;
  31321. private _pointerLockRequested;
  31322. private _dummyFramebuffer;
  31323. private _rescalePostProcess;
  31324. /** @hidden */
  31325. protected _alphaMode: number;
  31326. /** @hidden */
  31327. protected _alphaEquation: number;
  31328. private _deterministicLockstep;
  31329. private _lockstepMaxSteps;
  31330. protected readonly _supportsHardwareTextureRescaling: boolean;
  31331. private _fps;
  31332. private _deltaTime;
  31333. /** @hidden */
  31334. _drawCalls: PerfCounter;
  31335. /**
  31336. * Turn this value on if you want to pause FPS computation when in background
  31337. */
  31338. disablePerformanceMonitorInBackground: boolean;
  31339. private _performanceMonitor;
  31340. /**
  31341. * Gets the performance monitor attached to this engine
  31342. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31343. */
  31344. readonly performanceMonitor: PerformanceMonitor;
  31345. private _onFocus;
  31346. private _onBlur;
  31347. private _onCanvasPointerOut;
  31348. private _onCanvasBlur;
  31349. private _onCanvasFocus;
  31350. private _onFullscreenChange;
  31351. private _onPointerLockChange;
  31352. /**
  31353. * Creates a new engine
  31354. * @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
  31355. * @param antialias defines enable antialiasing (default: false)
  31356. * @param options defines further options to be sent to the getContext() function
  31357. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31358. */
  31359. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31360. /**
  31361. * Gets current aspect ratio
  31362. * @param viewportOwner defines the camera to use to get the aspect ratio
  31363. * @param useScreen defines if screen size must be used (or the current render target if any)
  31364. * @returns a number defining the aspect ratio
  31365. */
  31366. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31367. /**
  31368. * Gets current screen aspect ratio
  31369. * @returns a number defining the aspect ratio
  31370. */
  31371. getScreenAspectRatio(): number;
  31372. /**
  31373. * Gets host document
  31374. * @returns the host document object
  31375. */
  31376. getHostDocument(): Document;
  31377. /**
  31378. * Gets the client rect of the HTML canvas attached with the current webGL context
  31379. * @returns a client rectanglee
  31380. */
  31381. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31382. /**
  31383. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31384. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31385. * @returns true if engine is in deterministic lock step mode
  31386. */
  31387. isDeterministicLockStep(): boolean;
  31388. /**
  31389. * Gets the max steps when engine is running in deterministic lock step
  31390. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31391. * @returns the max steps
  31392. */
  31393. getLockstepMaxSteps(): number;
  31394. /**
  31395. * Force the mipmap generation for the given render target texture
  31396. * @param texture defines the render target texture to use
  31397. */
  31398. generateMipMapsForCubemap(texture: InternalTexture): void;
  31399. /** States */
  31400. /**
  31401. * Set various states to the webGL context
  31402. * @param culling defines backface culling state
  31403. * @param zOffset defines the value to apply to zOffset (0 by default)
  31404. * @param force defines if states must be applied even if cache is up to date
  31405. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31406. */
  31407. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31408. /**
  31409. * Set the z offset to apply to current rendering
  31410. * @param value defines the offset to apply
  31411. */
  31412. setZOffset(value: number): void;
  31413. /**
  31414. * Gets the current value of the zOffset
  31415. * @returns the current zOffset state
  31416. */
  31417. getZOffset(): number;
  31418. /**
  31419. * Enable or disable depth buffering
  31420. * @param enable defines the state to set
  31421. */
  31422. setDepthBuffer(enable: boolean): void;
  31423. /**
  31424. * Gets a boolean indicating if depth writing is enabled
  31425. * @returns the current depth writing state
  31426. */
  31427. getDepthWrite(): boolean;
  31428. /**
  31429. * Enable or disable depth writing
  31430. * @param enable defines the state to set
  31431. */
  31432. setDepthWrite(enable: boolean): void;
  31433. /**
  31434. * Enable or disable color writing
  31435. * @param enable defines the state to set
  31436. */
  31437. setColorWrite(enable: boolean): void;
  31438. /**
  31439. * Gets a boolean indicating if color writing is enabled
  31440. * @returns the current color writing state
  31441. */
  31442. getColorWrite(): boolean;
  31443. /**
  31444. * Sets alpha constants used by some alpha blending modes
  31445. * @param r defines the red component
  31446. * @param g defines the green component
  31447. * @param b defines the blue component
  31448. * @param a defines the alpha component
  31449. */
  31450. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31451. /**
  31452. * Sets the current alpha mode
  31453. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31454. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31455. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31456. */
  31457. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31458. /**
  31459. * Gets the current alpha mode
  31460. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31461. * @returns the current alpha mode
  31462. */
  31463. getAlphaMode(): number;
  31464. /**
  31465. * Sets the current alpha equation
  31466. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31467. */
  31468. setAlphaEquation(equation: number): void;
  31469. /**
  31470. * Gets the current alpha equation.
  31471. * @returns the current alpha equation
  31472. */
  31473. getAlphaEquation(): number;
  31474. /**
  31475. * Gets a boolean indicating if stencil buffer is enabled
  31476. * @returns the current stencil buffer state
  31477. */
  31478. getStencilBuffer(): boolean;
  31479. /**
  31480. * Enable or disable the stencil buffer
  31481. * @param enable defines if the stencil buffer must be enabled or disabled
  31482. */
  31483. setStencilBuffer(enable: boolean): void;
  31484. /**
  31485. * Gets the current stencil mask
  31486. * @returns a number defining the new stencil mask to use
  31487. */
  31488. getStencilMask(): number;
  31489. /**
  31490. * Sets the current stencil mask
  31491. * @param mask defines the new stencil mask to use
  31492. */
  31493. setStencilMask(mask: number): void;
  31494. /**
  31495. * Gets the current stencil function
  31496. * @returns a number defining the stencil function to use
  31497. */
  31498. getStencilFunction(): number;
  31499. /**
  31500. * Gets the current stencil reference value
  31501. * @returns a number defining the stencil reference value to use
  31502. */
  31503. getStencilFunctionReference(): number;
  31504. /**
  31505. * Gets the current stencil mask
  31506. * @returns a number defining the stencil mask to use
  31507. */
  31508. getStencilFunctionMask(): number;
  31509. /**
  31510. * Sets the current stencil function
  31511. * @param stencilFunc defines the new stencil function to use
  31512. */
  31513. setStencilFunction(stencilFunc: number): void;
  31514. /**
  31515. * Sets the current stencil reference
  31516. * @param reference defines the new stencil reference to use
  31517. */
  31518. setStencilFunctionReference(reference: number): void;
  31519. /**
  31520. * Sets the current stencil mask
  31521. * @param mask defines the new stencil mask to use
  31522. */
  31523. setStencilFunctionMask(mask: number): void;
  31524. /**
  31525. * Gets the current stencil operation when stencil fails
  31526. * @returns a number defining stencil operation to use when stencil fails
  31527. */
  31528. getStencilOperationFail(): number;
  31529. /**
  31530. * Gets the current stencil operation when depth fails
  31531. * @returns a number defining stencil operation to use when depth fails
  31532. */
  31533. getStencilOperationDepthFail(): number;
  31534. /**
  31535. * Gets the current stencil operation when stencil passes
  31536. * @returns a number defining stencil operation to use when stencil passes
  31537. */
  31538. getStencilOperationPass(): number;
  31539. /**
  31540. * Sets the stencil operation to use when stencil fails
  31541. * @param operation defines the stencil operation to use when stencil fails
  31542. */
  31543. setStencilOperationFail(operation: number): void;
  31544. /**
  31545. * Sets the stencil operation to use when depth fails
  31546. * @param operation defines the stencil operation to use when depth fails
  31547. */
  31548. setStencilOperationDepthFail(operation: number): void;
  31549. /**
  31550. * Sets the stencil operation to use when stencil passes
  31551. * @param operation defines the stencil operation to use when stencil passes
  31552. */
  31553. setStencilOperationPass(operation: number): void;
  31554. /**
  31555. * Sets a boolean indicating if the dithering state is enabled or disabled
  31556. * @param value defines the dithering state
  31557. */
  31558. setDitheringState(value: boolean): void;
  31559. /**
  31560. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31561. * @param value defines the rasterizer state
  31562. */
  31563. setRasterizerState(value: boolean): void;
  31564. /**
  31565. * Gets the current depth function
  31566. * @returns a number defining the depth function
  31567. */
  31568. getDepthFunction(): Nullable<number>;
  31569. /**
  31570. * Sets the current depth function
  31571. * @param depthFunc defines the function to use
  31572. */
  31573. setDepthFunction(depthFunc: number): void;
  31574. /**
  31575. * Sets the current depth function to GREATER
  31576. */
  31577. setDepthFunctionToGreater(): void;
  31578. /**
  31579. * Sets the current depth function to GEQUAL
  31580. */
  31581. setDepthFunctionToGreaterOrEqual(): void;
  31582. /**
  31583. * Sets the current depth function to LESS
  31584. */
  31585. setDepthFunctionToLess(): void;
  31586. /**
  31587. * Sets the current depth function to LEQUAL
  31588. */
  31589. setDepthFunctionToLessOrEqual(): void;
  31590. private _cachedStencilBuffer;
  31591. private _cachedStencilFunction;
  31592. private _cachedStencilMask;
  31593. private _cachedStencilOperationPass;
  31594. private _cachedStencilOperationFail;
  31595. private _cachedStencilOperationDepthFail;
  31596. private _cachedStencilReference;
  31597. /**
  31598. * Caches the the state of the stencil buffer
  31599. */
  31600. cacheStencilState(): void;
  31601. /**
  31602. * Restores the state of the stencil buffer
  31603. */
  31604. restoreStencilState(): void;
  31605. /**
  31606. * Directly set the WebGL Viewport
  31607. * @param x defines the x coordinate of the viewport (in screen space)
  31608. * @param y defines the y coordinate of the viewport (in screen space)
  31609. * @param width defines the width of the viewport (in screen space)
  31610. * @param height defines the height of the viewport (in screen space)
  31611. * @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
  31612. */
  31613. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31614. /**
  31615. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31616. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31617. * @param y defines the y-coordinate of the corner of the clear rectangle
  31618. * @param width defines the width of the clear rectangle
  31619. * @param height defines the height of the clear rectangle
  31620. * @param clearColor defines the clear color
  31621. */
  31622. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31623. /**
  31624. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31625. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31626. * @param y defines the y-coordinate of the corner of the clear rectangle
  31627. * @param width defines the width of the clear rectangle
  31628. * @param height defines the height of the clear rectangle
  31629. */
  31630. enableScissor(x: number, y: number, width: number, height: number): void;
  31631. /**
  31632. * Disable previously set scissor test rectangle
  31633. */
  31634. disableScissor(): void;
  31635. protected _reportDrawCall(): void;
  31636. /**
  31637. * Initializes a webVR display and starts listening to display change events
  31638. * The onVRDisplayChangedObservable will be notified upon these changes
  31639. * @returns The onVRDisplayChangedObservable
  31640. */
  31641. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31642. /** @hidden */
  31643. _prepareVRComponent(): void;
  31644. /** @hidden */
  31645. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31646. /** @hidden */
  31647. _submitVRFrame(): void;
  31648. /**
  31649. * Call this function to leave webVR mode
  31650. * Will do nothing if webVR is not supported or if there is no webVR device
  31651. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31652. */
  31653. disableVR(): void;
  31654. /**
  31655. * Gets a boolean indicating that the system is in VR mode and is presenting
  31656. * @returns true if VR mode is engaged
  31657. */
  31658. isVRPresenting(): boolean;
  31659. /** @hidden */
  31660. _requestVRFrame(): void;
  31661. /** @hidden */
  31662. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31663. /**
  31664. * Gets the source code of the vertex shader associated with a specific webGL program
  31665. * @param program defines the program to use
  31666. * @returns a string containing the source code of the vertex shader associated with the program
  31667. */
  31668. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31669. /**
  31670. * Gets the source code of the fragment shader associated with a specific webGL program
  31671. * @param program defines the program to use
  31672. * @returns a string containing the source code of the fragment shader associated with the program
  31673. */
  31674. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31675. /**
  31676. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31677. * @param x defines the x coordinate of the rectangle where pixels must be read
  31678. * @param y defines the y coordinate of the rectangle where pixels must be read
  31679. * @param width defines the width of the rectangle where pixels must be read
  31680. * @param height defines the height of the rectangle where pixels must be read
  31681. * @returns a Uint8Array containing RGBA colors
  31682. */
  31683. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31684. /**
  31685. * Sets a depth stencil texture from a render target to the according uniform.
  31686. * @param channel The texture channel
  31687. * @param uniform The uniform to set
  31688. * @param texture The render target texture containing the depth stencil texture to apply
  31689. */
  31690. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31691. /**
  31692. * Sets a texture to the webGL context from a postprocess
  31693. * @param channel defines the channel to use
  31694. * @param postProcess defines the source postprocess
  31695. */
  31696. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31697. /**
  31698. * Binds the output of the passed in post process to the texture channel specified
  31699. * @param channel The channel the texture should be bound to
  31700. * @param postProcess The post process which's output should be bound
  31701. */
  31702. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31703. /** @hidden */
  31704. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31705. protected _rebuildBuffers(): void;
  31706. _renderLoop(): void;
  31707. /**
  31708. * Toggle full screen mode
  31709. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31710. */
  31711. switchFullscreen(requestPointerLock: boolean): void;
  31712. /**
  31713. * Enters full screen mode
  31714. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31715. */
  31716. enterFullscreen(requestPointerLock: boolean): void;
  31717. /**
  31718. * Exits full screen mode
  31719. */
  31720. exitFullscreen(): void;
  31721. /**
  31722. * Enters Pointerlock mode
  31723. */
  31724. enterPointerlock(): void;
  31725. /**
  31726. * Exits Pointerlock mode
  31727. */
  31728. exitPointerlock(): void;
  31729. /**
  31730. * Begin a new frame
  31731. */
  31732. beginFrame(): void;
  31733. /**
  31734. * Enf the current frame
  31735. */
  31736. endFrame(): void;
  31737. resize(): void;
  31738. /**
  31739. * Set the compressed texture format to use, based on the formats you have, and the formats
  31740. * supported by the hardware / browser.
  31741. *
  31742. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31743. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31744. * to API arguments needed to compressed textures. This puts the burden on the container
  31745. * generator to house the arcane code for determining these for current & future formats.
  31746. *
  31747. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31748. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31749. *
  31750. * Note: The result of this call is not taken into account when a texture is base64.
  31751. *
  31752. * @param formatsAvailable defines the list of those format families you have created
  31753. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31754. *
  31755. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31756. * @returns The extension selected.
  31757. */
  31758. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31759. /**
  31760. * Force a specific size of the canvas
  31761. * @param width defines the new canvas' width
  31762. * @param height defines the new canvas' height
  31763. */
  31764. setSize(width: number, height: number): void;
  31765. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31766. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31767. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31768. _releaseTexture(texture: InternalTexture): void;
  31769. /**
  31770. * @hidden
  31771. * Rescales a texture
  31772. * @param source input texutre
  31773. * @param destination destination texture
  31774. * @param scene scene to use to render the resize
  31775. * @param internalFormat format to use when resizing
  31776. * @param onComplete callback to be called when resize has completed
  31777. */
  31778. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31779. /**
  31780. * Gets the current framerate
  31781. * @returns a number representing the framerate
  31782. */
  31783. getFps(): number;
  31784. /**
  31785. * Gets the time spent between current and previous frame
  31786. * @returns a number representing the delta time in ms
  31787. */
  31788. getDeltaTime(): number;
  31789. private _measureFps;
  31790. /**
  31791. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31792. * @param renderTarget The render target to set the frame buffer for
  31793. */
  31794. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31795. /**
  31796. * Update a dynamic index buffer
  31797. * @param indexBuffer defines the target index buffer
  31798. * @param indices defines the data to update
  31799. * @param offset defines the offset in the target index buffer where update should start
  31800. */
  31801. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31802. /**
  31803. * Creates a new render target texture
  31804. * @param size defines the size of the texture
  31805. * @param options defines the options used to create the texture
  31806. * @returns a new render target texture stored in an InternalTexture
  31807. */
  31808. createRenderTargetTexture(size: number | {
  31809. width: number;
  31810. height: number;
  31811. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31812. /**
  31813. * Updates the sample count of a render target texture
  31814. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31815. * @param texture defines the texture to update
  31816. * @param samples defines the sample count to set
  31817. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31818. */
  31819. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31820. /** @hidden */
  31821. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31822. dispose(): void;
  31823. private _disableTouchAction;
  31824. /**
  31825. * Display the loading screen
  31826. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31827. */
  31828. displayLoadingUI(): void;
  31829. /**
  31830. * Hide the loading screen
  31831. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31832. */
  31833. hideLoadingUI(): void;
  31834. /**
  31835. * Gets the current loading screen object
  31836. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31837. */
  31838. /**
  31839. * Sets the current loading screen object
  31840. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31841. */
  31842. loadingScreen: ILoadingScreen;
  31843. /**
  31844. * Sets the current loading screen text
  31845. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31846. */
  31847. loadingUIText: string;
  31848. /**
  31849. * Sets the current loading screen background color
  31850. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31851. */
  31852. loadingUIBackgroundColor: string;
  31853. /** Pointerlock and fullscreen */
  31854. /**
  31855. * Ask the browser to promote the current element to pointerlock mode
  31856. * @param element defines the DOM element to promote
  31857. */
  31858. static _RequestPointerlock(element: HTMLElement): void;
  31859. /**
  31860. * Asks the browser to exit pointerlock mode
  31861. */
  31862. static _ExitPointerlock(): void;
  31863. /**
  31864. * Ask the browser to promote the current element to fullscreen rendering mode
  31865. * @param element defines the DOM element to promote
  31866. */
  31867. static _RequestFullscreen(element: HTMLElement): void;
  31868. /**
  31869. * Asks the browser to exit fullscreen mode
  31870. */
  31871. static _ExitFullscreen(): void;
  31872. }
  31873. }
  31874. declare module BABYLON {
  31875. /**
  31876. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31877. * during the life time of the application.
  31878. */
  31879. export class EngineStore {
  31880. /** Gets the list of created engines */
  31881. static Instances: Engine[];
  31882. /** @hidden */
  31883. static _LastCreatedScene: Nullable<Scene>;
  31884. /**
  31885. * Gets the latest created engine
  31886. */
  31887. static readonly LastCreatedEngine: Nullable<Engine>;
  31888. /**
  31889. * Gets the latest created scene
  31890. */
  31891. static readonly LastCreatedScene: Nullable<Scene>;
  31892. /**
  31893. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31894. * @ignorenaming
  31895. */
  31896. static UseFallbackTexture: boolean;
  31897. /**
  31898. * Texture content used if a texture cannot loaded
  31899. * @ignorenaming
  31900. */
  31901. static FallbackTexture: string;
  31902. }
  31903. }
  31904. declare module BABYLON {
  31905. /**
  31906. * Helper class that provides a small promise polyfill
  31907. */
  31908. export class PromisePolyfill {
  31909. /**
  31910. * Static function used to check if the polyfill is required
  31911. * If this is the case then the function will inject the polyfill to window.Promise
  31912. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31913. */
  31914. static Apply(force?: boolean): void;
  31915. }
  31916. }
  31917. declare module BABYLON {
  31918. /**
  31919. * Interface for screenshot methods with describe argument called `size` as object with options
  31920. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31921. */
  31922. export interface IScreenshotSize {
  31923. /**
  31924. * number in pixels for canvas height
  31925. */
  31926. height?: number;
  31927. /**
  31928. * multiplier allowing render at a higher or lower resolution
  31929. * If value is defined then height and width will be ignored and taken from camera
  31930. */
  31931. precision?: number;
  31932. /**
  31933. * number in pixels for canvas width
  31934. */
  31935. width?: number;
  31936. }
  31937. }
  31938. declare module BABYLON {
  31939. interface IColor4Like {
  31940. r: float;
  31941. g: float;
  31942. b: float;
  31943. a: float;
  31944. }
  31945. /**
  31946. * Class containing a set of static utilities functions
  31947. */
  31948. export class Tools {
  31949. /**
  31950. * Gets or sets the base URL to use to load assets
  31951. */
  31952. static BaseUrl: string;
  31953. /**
  31954. * Enable/Disable Custom HTTP Request Headers globally.
  31955. * default = false
  31956. * @see CustomRequestHeaders
  31957. */
  31958. static UseCustomRequestHeaders: boolean;
  31959. /**
  31960. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31961. * i.e. when loading files, where the server/service expects an Authorization header
  31962. */
  31963. static CustomRequestHeaders: {
  31964. [key: string]: string;
  31965. };
  31966. /**
  31967. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31968. */
  31969. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31970. /**
  31971. * Default behaviour for cors in the application.
  31972. * It can be a string if the expected behavior is identical in the entire app.
  31973. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31974. */
  31975. static CorsBehavior: string | ((url: string | string[]) => string);
  31976. /**
  31977. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31978. * @ignorenaming
  31979. */
  31980. static UseFallbackTexture: boolean;
  31981. /**
  31982. * Use this object to register external classes like custom textures or material
  31983. * to allow the laoders to instantiate them
  31984. */
  31985. static RegisteredExternalClasses: {
  31986. [key: string]: Object;
  31987. };
  31988. /**
  31989. * Texture content used if a texture cannot loaded
  31990. * @ignorenaming
  31991. */
  31992. static fallbackTexture: string;
  31993. /**
  31994. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31995. * @param u defines the coordinate on X axis
  31996. * @param v defines the coordinate on Y axis
  31997. * @param width defines the width of the source data
  31998. * @param height defines the height of the source data
  31999. * @param pixels defines the source byte array
  32000. * @param color defines the output color
  32001. */
  32002. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32003. /**
  32004. * Interpolates between a and b via alpha
  32005. * @param a The lower value (returned when alpha = 0)
  32006. * @param b The upper value (returned when alpha = 1)
  32007. * @param alpha The interpolation-factor
  32008. * @return The mixed value
  32009. */
  32010. static Mix(a: number, b: number, alpha: number): number;
  32011. /**
  32012. * Tries to instantiate a new object from a given class name
  32013. * @param className defines the class name to instantiate
  32014. * @returns the new object or null if the system was not able to do the instantiation
  32015. */
  32016. static Instantiate(className: string): any;
  32017. /**
  32018. * Provides a slice function that will work even on IE
  32019. * @param data defines the array to slice
  32020. * @param start defines the start of the data (optional)
  32021. * @param end defines the end of the data (optional)
  32022. * @returns the new sliced array
  32023. */
  32024. static Slice<T>(data: T, start?: number, end?: number): T;
  32025. /**
  32026. * Polyfill for setImmediate
  32027. * @param action defines the action to execute after the current execution block
  32028. */
  32029. static SetImmediate(action: () => void): void;
  32030. /**
  32031. * Function indicating if a number is an exponent of 2
  32032. * @param value defines the value to test
  32033. * @returns true if the value is an exponent of 2
  32034. */
  32035. static IsExponentOfTwo(value: number): boolean;
  32036. private static _tmpFloatArray;
  32037. /**
  32038. * Returns the nearest 32-bit single precision float representation of a Number
  32039. * @param value A Number. If the parameter is of a different type, it will get converted
  32040. * to a number or to NaN if it cannot be converted
  32041. * @returns number
  32042. */
  32043. static FloatRound(value: number): number;
  32044. /**
  32045. * Extracts the filename from a path
  32046. * @param path defines the path to use
  32047. * @returns the filename
  32048. */
  32049. static GetFilename(path: string): string;
  32050. /**
  32051. * Extracts the "folder" part of a path (everything before the filename).
  32052. * @param uri The URI to extract the info from
  32053. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32054. * @returns The "folder" part of the path
  32055. */
  32056. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32057. /**
  32058. * Extracts text content from a DOM element hierarchy
  32059. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32060. */
  32061. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32062. /**
  32063. * Convert an angle in radians to degrees
  32064. * @param angle defines the angle to convert
  32065. * @returns the angle in degrees
  32066. */
  32067. static ToDegrees(angle: number): number;
  32068. /**
  32069. * Convert an angle in degrees to radians
  32070. * @param angle defines the angle to convert
  32071. * @returns the angle in radians
  32072. */
  32073. static ToRadians(angle: number): number;
  32074. /**
  32075. * Encode a buffer to a base64 string
  32076. * @param buffer defines the buffer to encode
  32077. * @returns the encoded string
  32078. */
  32079. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32080. /**
  32081. * Returns an array if obj is not an array
  32082. * @param obj defines the object to evaluate as an array
  32083. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32084. * @returns either obj directly if obj is an array or a new array containing obj
  32085. */
  32086. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32087. /**
  32088. * Gets the pointer prefix to use
  32089. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32090. */
  32091. static GetPointerPrefix(): string;
  32092. /**
  32093. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32094. * @param url define the url we are trying
  32095. * @param element define the dom element where to configure the cors policy
  32096. */
  32097. static SetCorsBehavior(url: string | string[], element: {
  32098. crossOrigin: string | null;
  32099. }): void;
  32100. /**
  32101. * Removes unwanted characters from an url
  32102. * @param url defines the url to clean
  32103. * @returns the cleaned url
  32104. */
  32105. static CleanUrl(url: string): string;
  32106. /**
  32107. * Gets or sets a function used to pre-process url before using them to load assets
  32108. */
  32109. static PreprocessUrl: (url: string) => string;
  32110. /**
  32111. * Loads an image as an HTMLImageElement.
  32112. * @param input url string, ArrayBuffer, or Blob to load
  32113. * @param onLoad callback called when the image successfully loads
  32114. * @param onError callback called when the image fails to load
  32115. * @param offlineProvider offline provider for caching
  32116. * @returns the HTMLImageElement of the loaded image
  32117. */
  32118. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32119. /**
  32120. * Loads a file
  32121. * @param url url string, ArrayBuffer, or Blob to load
  32122. * @param onSuccess callback called when the file successfully loads
  32123. * @param onProgress callback called while file is loading (if the server supports this mode)
  32124. * @param offlineProvider defines the offline provider for caching
  32125. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32126. * @param onError callback called when the file fails to load
  32127. * @returns a file request object
  32128. */
  32129. 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;
  32130. /**
  32131. * Loads a file from a url
  32132. * @param url the file url to load
  32133. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32134. */
  32135. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32136. /**
  32137. * Load a script (identified by an url). When the url returns, the
  32138. * content of this file is added into a new script element, attached to the DOM (body element)
  32139. * @param scriptUrl defines the url of the script to laod
  32140. * @param onSuccess defines the callback called when the script is loaded
  32141. * @param onError defines the callback to call if an error occurs
  32142. * @param scriptId defines the id of the script element
  32143. */
  32144. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32145. /**
  32146. * Load an asynchronous script (identified by an url). When the url returns, the
  32147. * content of this file is added into a new script element, attached to the DOM (body element)
  32148. * @param scriptUrl defines the url of the script to laod
  32149. * @param scriptId defines the id of the script element
  32150. * @returns a promise request object
  32151. */
  32152. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32153. /**
  32154. * Loads a file from a blob
  32155. * @param fileToLoad defines the blob to use
  32156. * @param callback defines the callback to call when data is loaded
  32157. * @param progressCallback defines the callback to call during loading process
  32158. * @returns a file request object
  32159. */
  32160. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32161. /**
  32162. * Loads a file
  32163. * @param fileToLoad defines the file to load
  32164. * @param callback defines the callback to call when data is loaded
  32165. * @param progressCallBack defines the callback to call during loading process
  32166. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32167. * @returns a file request object
  32168. */
  32169. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32170. /**
  32171. * Creates a data url from a given string content
  32172. * @param content defines the content to convert
  32173. * @returns the new data url link
  32174. */
  32175. static FileAsURL(content: string): string;
  32176. /**
  32177. * Format the given number to a specific decimal format
  32178. * @param value defines the number to format
  32179. * @param decimals defines the number of decimals to use
  32180. * @returns the formatted string
  32181. */
  32182. static Format(value: number, decimals?: number): string;
  32183. /**
  32184. * Tries to copy an object by duplicating every property
  32185. * @param source defines the source object
  32186. * @param destination defines the target object
  32187. * @param doNotCopyList defines a list of properties to avoid
  32188. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32189. */
  32190. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32191. /**
  32192. * Gets a boolean indicating if the given object has no own property
  32193. * @param obj defines the object to test
  32194. * @returns true if object has no own property
  32195. */
  32196. static IsEmpty(obj: any): boolean;
  32197. /**
  32198. * Function used to register events at window level
  32199. * @param windowElement defines the Window object to use
  32200. * @param events defines the events to register
  32201. */
  32202. static RegisterTopRootEvents(windowElement: Window, events: {
  32203. name: string;
  32204. handler: Nullable<(e: FocusEvent) => any>;
  32205. }[]): void;
  32206. /**
  32207. * Function used to unregister events from window level
  32208. * @param windowElement defines the Window object to use
  32209. * @param events defines the events to unregister
  32210. */
  32211. static UnregisterTopRootEvents(windowElement: Window, events: {
  32212. name: string;
  32213. handler: Nullable<(e: FocusEvent) => any>;
  32214. }[]): void;
  32215. /**
  32216. * @ignore
  32217. */
  32218. static _ScreenshotCanvas: HTMLCanvasElement;
  32219. /**
  32220. * Dumps the current bound framebuffer
  32221. * @param width defines the rendering width
  32222. * @param height defines the rendering height
  32223. * @param engine defines the hosting engine
  32224. * @param successCallback defines the callback triggered once the data are available
  32225. * @param mimeType defines the mime type of the result
  32226. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32227. */
  32228. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32229. /**
  32230. * Converts the canvas data to blob.
  32231. * This acts as a polyfill for browsers not supporting the to blob function.
  32232. * @param canvas Defines the canvas to extract the data from
  32233. * @param successCallback Defines the callback triggered once the data are available
  32234. * @param mimeType Defines the mime type of the result
  32235. */
  32236. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32237. /**
  32238. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32239. * @param successCallback defines the callback triggered once the data are available
  32240. * @param mimeType defines the mime type of the result
  32241. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32242. */
  32243. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32244. /**
  32245. * Downloads a blob in the browser
  32246. * @param blob defines the blob to download
  32247. * @param fileName defines the name of the downloaded file
  32248. */
  32249. static Download(blob: Blob, fileName: string): void;
  32250. /**
  32251. * Captures a screenshot of the current rendering
  32252. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32253. * @param engine defines the rendering engine
  32254. * @param camera defines the source camera
  32255. * @param size This parameter can be set to a single number or to an object with the
  32256. * following (optional) properties: precision, width, height. If a single number is passed,
  32257. * it will be used for both width and height. If an object is passed, the screenshot size
  32258. * will be derived from the parameters. The precision property is a multiplier allowing
  32259. * rendering at a higher or lower resolution
  32260. * @param successCallback defines the callback receives a single parameter which contains the
  32261. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32262. * src parameter of an <img> to display it
  32263. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32264. * Check your browser for supported MIME types
  32265. */
  32266. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32267. /**
  32268. * Captures a screenshot of the current rendering
  32269. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32270. * @param engine defines the rendering engine
  32271. * @param camera defines the source camera
  32272. * @param size This parameter can be set to a single number or to an object with the
  32273. * following (optional) properties: precision, width, height. If a single number is passed,
  32274. * it will be used for both width and height. If an object is passed, the screenshot size
  32275. * will be derived from the parameters. The precision property is a multiplier allowing
  32276. * rendering at a higher or lower resolution
  32277. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32278. * Check your browser for supported MIME types
  32279. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32280. * to the src parameter of an <img> to display it
  32281. */
  32282. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32283. /**
  32284. * Generates an image screenshot from the specified camera.
  32285. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32286. * @param engine The engine to use for rendering
  32287. * @param camera The camera to use for rendering
  32288. * @param size This parameter can be set to a single number or to an object with the
  32289. * following (optional) properties: precision, width, height. If a single number is passed,
  32290. * it will be used for both width and height. If an object is passed, the screenshot size
  32291. * will be derived from the parameters. The precision property is a multiplier allowing
  32292. * rendering at a higher or lower resolution
  32293. * @param successCallback The callback receives a single parameter which contains the
  32294. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32295. * src parameter of an <img> to display it
  32296. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32297. * Check your browser for supported MIME types
  32298. * @param samples Texture samples (default: 1)
  32299. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32300. * @param fileName A name for for the downloaded file.
  32301. */
  32302. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32303. /**
  32304. * Generates an image screenshot from the specified camera.
  32305. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32306. * @param engine The engine to use for rendering
  32307. * @param camera The camera to use for rendering
  32308. * @param size This parameter can be set to a single number or to an object with the
  32309. * following (optional) properties: precision, width, height. If a single number is passed,
  32310. * it will be used for both width and height. If an object is passed, the screenshot size
  32311. * will be derived from the parameters. The precision property is a multiplier allowing
  32312. * rendering at a higher or lower resolution
  32313. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32314. * Check your browser for supported MIME types
  32315. * @param samples Texture samples (default: 1)
  32316. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32317. * @param fileName A name for for the downloaded file.
  32318. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32319. * to the src parameter of an <img> to display it
  32320. */
  32321. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32322. /**
  32323. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32324. * Be aware Math.random() could cause collisions, but:
  32325. * "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"
  32326. * @returns a pseudo random id
  32327. */
  32328. static RandomId(): string;
  32329. /**
  32330. * Test if the given uri is a base64 string
  32331. * @param uri The uri to test
  32332. * @return True if the uri is a base64 string or false otherwise
  32333. */
  32334. static IsBase64(uri: string): boolean;
  32335. /**
  32336. * Decode the given base64 uri.
  32337. * @param uri The uri to decode
  32338. * @return The decoded base64 data.
  32339. */
  32340. static DecodeBase64(uri: string): ArrayBuffer;
  32341. /**
  32342. * Gets the absolute url.
  32343. * @param url the input url
  32344. * @return the absolute url
  32345. */
  32346. static GetAbsoluteUrl(url: string): string;
  32347. /**
  32348. * No log
  32349. */
  32350. static readonly NoneLogLevel: number;
  32351. /**
  32352. * Only message logs
  32353. */
  32354. static readonly MessageLogLevel: number;
  32355. /**
  32356. * Only warning logs
  32357. */
  32358. static readonly WarningLogLevel: number;
  32359. /**
  32360. * Only error logs
  32361. */
  32362. static readonly ErrorLogLevel: number;
  32363. /**
  32364. * All logs
  32365. */
  32366. static readonly AllLogLevel: number;
  32367. /**
  32368. * Gets a value indicating the number of loading errors
  32369. * @ignorenaming
  32370. */
  32371. static readonly errorsCount: number;
  32372. /**
  32373. * Callback called when a new log is added
  32374. */
  32375. static OnNewCacheEntry: (entry: string) => void;
  32376. /**
  32377. * Log a message to the console
  32378. * @param message defines the message to log
  32379. */
  32380. static Log(message: string): void;
  32381. /**
  32382. * Write a warning message to the console
  32383. * @param message defines the message to log
  32384. */
  32385. static Warn(message: string): void;
  32386. /**
  32387. * Write an error message to the console
  32388. * @param message defines the message to log
  32389. */
  32390. static Error(message: string): void;
  32391. /**
  32392. * Gets current log cache (list of logs)
  32393. */
  32394. static readonly LogCache: string;
  32395. /**
  32396. * Clears the log cache
  32397. */
  32398. static ClearLogCache(): void;
  32399. /**
  32400. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32401. */
  32402. static LogLevels: number;
  32403. /**
  32404. * Checks if the window object exists
  32405. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32406. */
  32407. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32408. /**
  32409. * No performance log
  32410. */
  32411. static readonly PerformanceNoneLogLevel: number;
  32412. /**
  32413. * Use user marks to log performance
  32414. */
  32415. static readonly PerformanceUserMarkLogLevel: number;
  32416. /**
  32417. * Log performance to the console
  32418. */
  32419. static readonly PerformanceConsoleLogLevel: number;
  32420. private static _performance;
  32421. /**
  32422. * Sets the current performance log level
  32423. */
  32424. static PerformanceLogLevel: number;
  32425. private static _StartPerformanceCounterDisabled;
  32426. private static _EndPerformanceCounterDisabled;
  32427. private static _StartUserMark;
  32428. private static _EndUserMark;
  32429. private static _StartPerformanceConsole;
  32430. private static _EndPerformanceConsole;
  32431. /**
  32432. * Starts a performance counter
  32433. */
  32434. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32435. /**
  32436. * Ends a specific performance coutner
  32437. */
  32438. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32439. /**
  32440. * Gets either window.performance.now() if supported or Date.now() else
  32441. */
  32442. static readonly Now: number;
  32443. /**
  32444. * This method will return the name of the class used to create the instance of the given object.
  32445. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32446. * @param object the object to get the class name from
  32447. * @param isType defines if the object is actually a type
  32448. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32449. */
  32450. static GetClassName(object: any, isType?: boolean): string;
  32451. /**
  32452. * Gets the first element of an array satisfying a given predicate
  32453. * @param array defines the array to browse
  32454. * @param predicate defines the predicate to use
  32455. * @returns null if not found or the element
  32456. */
  32457. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32458. /**
  32459. * This method will return the name of the full name of the class, including its owning module (if any).
  32460. * 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).
  32461. * @param object the object to get the class name from
  32462. * @param isType defines if the object is actually a type
  32463. * @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.
  32464. * @ignorenaming
  32465. */
  32466. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32467. /**
  32468. * Returns a promise that resolves after the given amount of time.
  32469. * @param delay Number of milliseconds to delay
  32470. * @returns Promise that resolves after the given amount of time
  32471. */
  32472. static DelayAsync(delay: number): Promise<void>;
  32473. }
  32474. /**
  32475. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32476. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32477. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32478. * @param name The name of the class, case should be preserved
  32479. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32480. */
  32481. export function className(name: string, module?: string): (target: Object) => void;
  32482. /**
  32483. * An implementation of a loop for asynchronous functions.
  32484. */
  32485. export class AsyncLoop {
  32486. /**
  32487. * Defines the number of iterations for the loop
  32488. */
  32489. iterations: number;
  32490. /**
  32491. * Defines the current index of the loop.
  32492. */
  32493. index: number;
  32494. private _done;
  32495. private _fn;
  32496. private _successCallback;
  32497. /**
  32498. * Constructor.
  32499. * @param iterations the number of iterations.
  32500. * @param func the function to run each iteration
  32501. * @param successCallback the callback that will be called upon succesful execution
  32502. * @param offset starting offset.
  32503. */
  32504. constructor(
  32505. /**
  32506. * Defines the number of iterations for the loop
  32507. */
  32508. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32509. /**
  32510. * Execute the next iteration. Must be called after the last iteration was finished.
  32511. */
  32512. executeNext(): void;
  32513. /**
  32514. * Break the loop and run the success callback.
  32515. */
  32516. breakLoop(): void;
  32517. /**
  32518. * Create and run an async loop.
  32519. * @param iterations the number of iterations.
  32520. * @param fn the function to run each iteration
  32521. * @param successCallback the callback that will be called upon succesful execution
  32522. * @param offset starting offset.
  32523. * @returns the created async loop object
  32524. */
  32525. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32526. /**
  32527. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32528. * @param iterations total number of iterations
  32529. * @param syncedIterations number of synchronous iterations in each async iteration.
  32530. * @param fn the function to call each iteration.
  32531. * @param callback a success call back that will be called when iterating stops.
  32532. * @param breakFunction a break condition (optional)
  32533. * @param timeout timeout settings for the setTimeout function. default - 0.
  32534. * @returns the created async loop object
  32535. */
  32536. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32537. }
  32538. }
  32539. declare module BABYLON {
  32540. /**
  32541. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32542. * The underlying implementation relies on an associative array to ensure the best performances.
  32543. * The value can be anything including 'null' but except 'undefined'
  32544. */
  32545. export class StringDictionary<T> {
  32546. /**
  32547. * This will clear this dictionary and copy the content from the 'source' one.
  32548. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32549. * @param source the dictionary to take the content from and copy to this dictionary
  32550. */
  32551. copyFrom(source: StringDictionary<T>): void;
  32552. /**
  32553. * Get a value based from its key
  32554. * @param key the given key to get the matching value from
  32555. * @return the value if found, otherwise undefined is returned
  32556. */
  32557. get(key: string): T | undefined;
  32558. /**
  32559. * Get a value from its key or add it if it doesn't exist.
  32560. * This method will ensure you that a given key/data will be present in the dictionary.
  32561. * @param key the given key to get the matching value from
  32562. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32563. * The factory will only be invoked if there's no data for the given key.
  32564. * @return the value corresponding to the key.
  32565. */
  32566. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32567. /**
  32568. * Get a value from its key if present in the dictionary otherwise add it
  32569. * @param key the key to get the value from
  32570. * @param val if there's no such key/value pair in the dictionary add it with this value
  32571. * @return the value corresponding to the key
  32572. */
  32573. getOrAdd(key: string, val: T): T;
  32574. /**
  32575. * Check if there's a given key in the dictionary
  32576. * @param key the key to check for
  32577. * @return true if the key is present, false otherwise
  32578. */
  32579. contains(key: string): boolean;
  32580. /**
  32581. * Add a new key and its corresponding value
  32582. * @param key the key to add
  32583. * @param value the value corresponding to the key
  32584. * @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
  32585. */
  32586. add(key: string, value: T): boolean;
  32587. /**
  32588. * Update a specific value associated to a key
  32589. * @param key defines the key to use
  32590. * @param value defines the value to store
  32591. * @returns true if the value was updated (or false if the key was not found)
  32592. */
  32593. set(key: string, value: T): boolean;
  32594. /**
  32595. * Get the element of the given key and remove it from the dictionary
  32596. * @param key defines the key to search
  32597. * @returns the value associated with the key or null if not found
  32598. */
  32599. getAndRemove(key: string): Nullable<T>;
  32600. /**
  32601. * Remove a key/value from the dictionary.
  32602. * @param key the key to remove
  32603. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32604. */
  32605. remove(key: string): boolean;
  32606. /**
  32607. * Clear the whole content of the dictionary
  32608. */
  32609. clear(): void;
  32610. /**
  32611. * Gets the current count
  32612. */
  32613. readonly count: number;
  32614. /**
  32615. * Execute a callback on each key/val of the dictionary.
  32616. * Note that you can remove any element in this dictionary in the callback implementation
  32617. * @param callback the callback to execute on a given key/value pair
  32618. */
  32619. forEach(callback: (key: string, val: T) => void): void;
  32620. /**
  32621. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32622. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32623. * Note that you can remove any element in this dictionary in the callback implementation
  32624. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32625. * @returns the first item
  32626. */
  32627. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32628. private _count;
  32629. private _data;
  32630. }
  32631. }
  32632. declare module BABYLON {
  32633. /** @hidden */
  32634. export interface ICollisionCoordinator {
  32635. createCollider(): Collider;
  32636. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32637. init(scene: Scene): void;
  32638. }
  32639. /** @hidden */
  32640. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32641. private _scene;
  32642. private _scaledPosition;
  32643. private _scaledVelocity;
  32644. private _finalPosition;
  32645. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32646. createCollider(): Collider;
  32647. init(scene: Scene): void;
  32648. private _collideWithWorld;
  32649. }
  32650. }
  32651. declare module BABYLON {
  32652. /**
  32653. * Class used to manage all inputs for the scene.
  32654. */
  32655. export class InputManager {
  32656. /** The distance in pixel that you have to move to prevent some events */
  32657. static DragMovementThreshold: number;
  32658. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32659. static LongPressDelay: number;
  32660. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32661. static DoubleClickDelay: number;
  32662. /** If you need to check double click without raising a single click at first click, enable this flag */
  32663. static ExclusiveDoubleClickMode: boolean;
  32664. private _wheelEventName;
  32665. private _onPointerMove;
  32666. private _onPointerDown;
  32667. private _onPointerUp;
  32668. private _initClickEvent;
  32669. private _initActionManager;
  32670. private _delayedSimpleClick;
  32671. private _delayedSimpleClickTimeout;
  32672. private _previousDelayedSimpleClickTimeout;
  32673. private _meshPickProceed;
  32674. private _previousButtonPressed;
  32675. private _currentPickResult;
  32676. private _previousPickResult;
  32677. private _totalPointersPressed;
  32678. private _doubleClickOccured;
  32679. private _pointerOverMesh;
  32680. private _pickedDownMesh;
  32681. private _pickedUpMesh;
  32682. private _pointerX;
  32683. private _pointerY;
  32684. private _unTranslatedPointerX;
  32685. private _unTranslatedPointerY;
  32686. private _startingPointerPosition;
  32687. private _previousStartingPointerPosition;
  32688. private _startingPointerTime;
  32689. private _previousStartingPointerTime;
  32690. private _pointerCaptures;
  32691. private _onKeyDown;
  32692. private _onKeyUp;
  32693. private _onCanvasFocusObserver;
  32694. private _onCanvasBlurObserver;
  32695. private _scene;
  32696. /**
  32697. * Creates a new InputManager
  32698. * @param scene defines the hosting scene
  32699. */
  32700. constructor(scene: Scene);
  32701. /**
  32702. * Gets the mesh that is currently under the pointer
  32703. */
  32704. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32705. /**
  32706. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32707. */
  32708. readonly unTranslatedPointer: Vector2;
  32709. /**
  32710. * Gets or sets the current on-screen X position of the pointer
  32711. */
  32712. pointerX: number;
  32713. /**
  32714. * Gets or sets the current on-screen Y position of the pointer
  32715. */
  32716. pointerY: number;
  32717. private _updatePointerPosition;
  32718. private _processPointerMove;
  32719. private _setRayOnPointerInfo;
  32720. private _checkPrePointerObservable;
  32721. /**
  32722. * Use this method to simulate a pointer move on a mesh
  32723. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32724. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32725. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32726. */
  32727. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32728. /**
  32729. * Use this method to simulate a pointer down on a mesh
  32730. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32731. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32732. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32733. */
  32734. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32735. private _processPointerDown;
  32736. /** @hidden */
  32737. _isPointerSwiping(): boolean;
  32738. /**
  32739. * Use this method to simulate a pointer up on a mesh
  32740. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32741. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32742. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32743. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32744. */
  32745. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32746. private _processPointerUp;
  32747. /**
  32748. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32749. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32750. * @returns true if the pointer was captured
  32751. */
  32752. isPointerCaptured(pointerId?: number): boolean;
  32753. /**
  32754. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32755. * @param attachUp defines if you want to attach events to pointerup
  32756. * @param attachDown defines if you want to attach events to pointerdown
  32757. * @param attachMove defines if you want to attach events to pointermove
  32758. */
  32759. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32760. /**
  32761. * Detaches all event handlers
  32762. */
  32763. detachControl(): void;
  32764. /**
  32765. * Force the value of meshUnderPointer
  32766. * @param mesh defines the mesh to use
  32767. */
  32768. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32769. /**
  32770. * Gets the mesh under the pointer
  32771. * @returns a Mesh or null if no mesh is under the pointer
  32772. */
  32773. getPointerOverMesh(): Nullable<AbstractMesh>;
  32774. }
  32775. }
  32776. declare module BABYLON {
  32777. /**
  32778. * Helper class used to generate session unique ID
  32779. */
  32780. export class UniqueIdGenerator {
  32781. private static _UniqueIdCounter;
  32782. /**
  32783. * Gets an unique (relatively to the current scene) Id
  32784. */
  32785. static readonly UniqueId: number;
  32786. }
  32787. }
  32788. declare module BABYLON {
  32789. /**
  32790. * This class defines the direct association between an animation and a target
  32791. */
  32792. export class TargetedAnimation {
  32793. /**
  32794. * Animation to perform
  32795. */
  32796. animation: Animation;
  32797. /**
  32798. * Target to animate
  32799. */
  32800. target: any;
  32801. /**
  32802. * Serialize the object
  32803. * @returns the JSON object representing the current entity
  32804. */
  32805. serialize(): any;
  32806. }
  32807. /**
  32808. * Use this class to create coordinated animations on multiple targets
  32809. */
  32810. export class AnimationGroup implements IDisposable {
  32811. /** The name of the animation group */
  32812. name: string;
  32813. private _scene;
  32814. private _targetedAnimations;
  32815. private _animatables;
  32816. private _from;
  32817. private _to;
  32818. private _isStarted;
  32819. private _isPaused;
  32820. private _speedRatio;
  32821. private _loopAnimation;
  32822. /**
  32823. * Gets or sets the unique id of the node
  32824. */
  32825. uniqueId: number;
  32826. /**
  32827. * This observable will notify when one animation have ended
  32828. */
  32829. onAnimationEndObservable: Observable<TargetedAnimation>;
  32830. /**
  32831. * Observer raised when one animation loops
  32832. */
  32833. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32834. /**
  32835. * This observable will notify when all animations have ended.
  32836. */
  32837. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32838. /**
  32839. * This observable will notify when all animations have paused.
  32840. */
  32841. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32842. /**
  32843. * This observable will notify when all animations are playing.
  32844. */
  32845. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32846. /**
  32847. * Gets the first frame
  32848. */
  32849. readonly from: number;
  32850. /**
  32851. * Gets the last frame
  32852. */
  32853. readonly to: number;
  32854. /**
  32855. * Define if the animations are started
  32856. */
  32857. readonly isStarted: boolean;
  32858. /**
  32859. * Gets a value indicating that the current group is playing
  32860. */
  32861. readonly isPlaying: boolean;
  32862. /**
  32863. * Gets or sets the speed ratio to use for all animations
  32864. */
  32865. /**
  32866. * Gets or sets the speed ratio to use for all animations
  32867. */
  32868. speedRatio: number;
  32869. /**
  32870. * Gets or sets if all animations should loop or not
  32871. */
  32872. loopAnimation: boolean;
  32873. /**
  32874. * Gets the targeted animations for this animation group
  32875. */
  32876. readonly targetedAnimations: Array<TargetedAnimation>;
  32877. /**
  32878. * returning the list of animatables controlled by this animation group.
  32879. */
  32880. readonly animatables: Array<Animatable>;
  32881. /**
  32882. * Instantiates a new Animation Group.
  32883. * This helps managing several animations at once.
  32884. * @see http://doc.babylonjs.com/how_to/group
  32885. * @param name Defines the name of the group
  32886. * @param scene Defines the scene the group belongs to
  32887. */
  32888. constructor(
  32889. /** The name of the animation group */
  32890. name: string, scene?: Nullable<Scene>);
  32891. /**
  32892. * Add an animation (with its target) in the group
  32893. * @param animation defines the animation we want to add
  32894. * @param target defines the target of the animation
  32895. * @returns the TargetedAnimation object
  32896. */
  32897. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32898. /**
  32899. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32900. * It can add constant keys at begin or end
  32901. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32902. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32903. * @returns the animation group
  32904. */
  32905. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32906. /**
  32907. * Start all animations on given targets
  32908. * @param loop defines if animations must loop
  32909. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32910. * @param from defines the from key (optional)
  32911. * @param to defines the to key (optional)
  32912. * @returns the current animation group
  32913. */
  32914. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32915. /**
  32916. * Pause all animations
  32917. * @returns the animation group
  32918. */
  32919. pause(): AnimationGroup;
  32920. /**
  32921. * Play all animations to initial state
  32922. * This function will start() the animations if they were not started or will restart() them if they were paused
  32923. * @param loop defines if animations must loop
  32924. * @returns the animation group
  32925. */
  32926. play(loop?: boolean): AnimationGroup;
  32927. /**
  32928. * Reset all animations to initial state
  32929. * @returns the animation group
  32930. */
  32931. reset(): AnimationGroup;
  32932. /**
  32933. * Restart animations from key 0
  32934. * @returns the animation group
  32935. */
  32936. restart(): AnimationGroup;
  32937. /**
  32938. * Stop all animations
  32939. * @returns the animation group
  32940. */
  32941. stop(): AnimationGroup;
  32942. /**
  32943. * Set animation weight for all animatables
  32944. * @param weight defines the weight to use
  32945. * @return the animationGroup
  32946. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32947. */
  32948. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32949. /**
  32950. * Synchronize and normalize all animatables with a source animatable
  32951. * @param root defines the root animatable to synchronize with
  32952. * @return the animationGroup
  32953. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32954. */
  32955. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32956. /**
  32957. * Goes to a specific frame in this animation group
  32958. * @param frame the frame number to go to
  32959. * @return the animationGroup
  32960. */
  32961. goToFrame(frame: number): AnimationGroup;
  32962. /**
  32963. * Dispose all associated resources
  32964. */
  32965. dispose(): void;
  32966. private _checkAnimationGroupEnded;
  32967. /**
  32968. * Clone the current animation group and returns a copy
  32969. * @param newName defines the name of the new group
  32970. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32971. * @returns the new aniamtion group
  32972. */
  32973. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32974. /**
  32975. * Serializes the animationGroup to an object
  32976. * @returns Serialized object
  32977. */
  32978. serialize(): any;
  32979. /**
  32980. * Returns a new AnimationGroup object parsed from the source provided.
  32981. * @param parsedAnimationGroup defines the source
  32982. * @param scene defines the scene that will receive the animationGroup
  32983. * @returns a new AnimationGroup
  32984. */
  32985. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32986. /**
  32987. * Returns the string "AnimationGroup"
  32988. * @returns "AnimationGroup"
  32989. */
  32990. getClassName(): string;
  32991. /**
  32992. * Creates a detailled string about the object
  32993. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32994. * @returns a string representing the object
  32995. */
  32996. toString(fullDetails?: boolean): string;
  32997. }
  32998. }
  32999. declare module BABYLON {
  33000. /**
  33001. * Define an interface for all classes that will hold resources
  33002. */
  33003. export interface IDisposable {
  33004. /**
  33005. * Releases all held resources
  33006. */
  33007. dispose(): void;
  33008. }
  33009. /** Interface defining initialization parameters for Scene class */
  33010. export interface SceneOptions {
  33011. /**
  33012. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33013. * It will improve performance when the number of geometries becomes important.
  33014. */
  33015. useGeometryUniqueIdsMap?: boolean;
  33016. /**
  33017. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33018. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33019. */
  33020. useMaterialMeshMap?: boolean;
  33021. /**
  33022. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33023. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33024. */
  33025. useClonedMeshhMap?: boolean;
  33026. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33027. virtual?: boolean;
  33028. }
  33029. /**
  33030. * Represents a scene to be rendered by the engine.
  33031. * @see http://doc.babylonjs.com/features/scene
  33032. */
  33033. export class Scene extends AbstractScene implements IAnimatable {
  33034. /** The fog is deactivated */
  33035. static readonly FOGMODE_NONE: number;
  33036. /** The fog density is following an exponential function */
  33037. static readonly FOGMODE_EXP: number;
  33038. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33039. static readonly FOGMODE_EXP2: number;
  33040. /** The fog density is following a linear function. */
  33041. static readonly FOGMODE_LINEAR: number;
  33042. /**
  33043. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33044. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33045. */
  33046. static MinDeltaTime: number;
  33047. /**
  33048. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33049. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33050. */
  33051. static MaxDeltaTime: number;
  33052. /**
  33053. * Factory used to create the default material.
  33054. * @param name The name of the material to create
  33055. * @param scene The scene to create the material for
  33056. * @returns The default material
  33057. */
  33058. static DefaultMaterialFactory(scene: Scene): Material;
  33059. /**
  33060. * Factory used to create the a collision coordinator.
  33061. * @returns The collision coordinator
  33062. */
  33063. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33064. /** @hidden */
  33065. _inputManager: InputManager;
  33066. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33067. cameraToUseForPointers: Nullable<Camera>;
  33068. /** @hidden */
  33069. readonly _isScene: boolean;
  33070. /**
  33071. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33072. */
  33073. autoClear: boolean;
  33074. /**
  33075. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33076. */
  33077. autoClearDepthAndStencil: boolean;
  33078. /**
  33079. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33080. */
  33081. clearColor: Color4;
  33082. /**
  33083. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33084. */
  33085. ambientColor: Color3;
  33086. /**
  33087. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33088. * It should only be one of the following (if not the default embedded one):
  33089. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33090. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33091. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33092. * The material properties need to be setup according to the type of texture in use.
  33093. */
  33094. environmentBRDFTexture: BaseTexture;
  33095. /** @hidden */
  33096. protected _environmentTexture: Nullable<BaseTexture>;
  33097. /**
  33098. * Texture used in all pbr material as the reflection texture.
  33099. * As in the majority of the scene they are the same (exception for multi room and so on),
  33100. * this is easier to reference from here than from all the materials.
  33101. */
  33102. /**
  33103. * Texture used in all pbr material as the reflection texture.
  33104. * As in the majority of the scene they are the same (exception for multi room and so on),
  33105. * this is easier to set here than in all the materials.
  33106. */
  33107. environmentTexture: Nullable<BaseTexture>;
  33108. /** @hidden */
  33109. protected _environmentIntensity: number;
  33110. /**
  33111. * Intensity of the environment in all pbr material.
  33112. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33113. * As in the majority of the scene they are the same (exception for multi room and so on),
  33114. * this is easier to reference from here than from all the materials.
  33115. */
  33116. /**
  33117. * Intensity of the environment in all pbr material.
  33118. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33119. * As in the majority of the scene they are the same (exception for multi room and so on),
  33120. * this is easier to set here than in all the materials.
  33121. */
  33122. environmentIntensity: number;
  33123. /** @hidden */
  33124. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33125. /**
  33126. * Default image processing configuration used either in the rendering
  33127. * Forward main pass or through the imageProcessingPostProcess if present.
  33128. * As in the majority of the scene they are the same (exception for multi camera),
  33129. * this is easier to reference from here than from all the materials and post process.
  33130. *
  33131. * No setter as we it is a shared configuration, you can set the values instead.
  33132. */
  33133. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33134. private _forceWireframe;
  33135. /**
  33136. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33137. */
  33138. forceWireframe: boolean;
  33139. private _forcePointsCloud;
  33140. /**
  33141. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33142. */
  33143. forcePointsCloud: boolean;
  33144. /**
  33145. * Gets or sets the active clipplane 1
  33146. */
  33147. clipPlane: Nullable<Plane>;
  33148. /**
  33149. * Gets or sets the active clipplane 2
  33150. */
  33151. clipPlane2: Nullable<Plane>;
  33152. /**
  33153. * Gets or sets the active clipplane 3
  33154. */
  33155. clipPlane3: Nullable<Plane>;
  33156. /**
  33157. * Gets or sets the active clipplane 4
  33158. */
  33159. clipPlane4: Nullable<Plane>;
  33160. /**
  33161. * Gets or sets a boolean indicating if animations are enabled
  33162. */
  33163. animationsEnabled: boolean;
  33164. private _animationPropertiesOverride;
  33165. /**
  33166. * Gets or sets the animation properties override
  33167. */
  33168. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33169. /**
  33170. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33171. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33172. */
  33173. useConstantAnimationDeltaTime: boolean;
  33174. /**
  33175. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33176. * Please note that it requires to run a ray cast through the scene on every frame
  33177. */
  33178. constantlyUpdateMeshUnderPointer: boolean;
  33179. /**
  33180. * Defines the HTML cursor to use when hovering over interactive elements
  33181. */
  33182. hoverCursor: string;
  33183. /**
  33184. * Defines the HTML default cursor to use (empty by default)
  33185. */
  33186. defaultCursor: string;
  33187. /**
  33188. * This is used to call preventDefault() on pointer down
  33189. * in order to block unwanted artifacts like system double clicks
  33190. */
  33191. preventDefaultOnPointerDown: boolean;
  33192. /**
  33193. * This is used to call preventDefault() on pointer up
  33194. * in order to block unwanted artifacts like system double clicks
  33195. */
  33196. preventDefaultOnPointerUp: boolean;
  33197. /**
  33198. * Gets or sets user defined metadata
  33199. */
  33200. metadata: any;
  33201. /**
  33202. * For internal use only. Please do not use.
  33203. */
  33204. reservedDataStore: any;
  33205. /**
  33206. * Gets the name of the plugin used to load this scene (null by default)
  33207. */
  33208. loadingPluginName: string;
  33209. /**
  33210. * Use this array to add regular expressions used to disable offline support for specific urls
  33211. */
  33212. disableOfflineSupportExceptionRules: RegExp[];
  33213. /**
  33214. * An event triggered when the scene is disposed.
  33215. */
  33216. onDisposeObservable: Observable<Scene>;
  33217. private _onDisposeObserver;
  33218. /** Sets a function to be executed when this scene is disposed. */
  33219. onDispose: () => void;
  33220. /**
  33221. * An event triggered before rendering the scene (right after animations and physics)
  33222. */
  33223. onBeforeRenderObservable: Observable<Scene>;
  33224. private _onBeforeRenderObserver;
  33225. /** Sets a function to be executed before rendering this scene */
  33226. beforeRender: Nullable<() => void>;
  33227. /**
  33228. * An event triggered after rendering the scene
  33229. */
  33230. onAfterRenderObservable: Observable<Scene>;
  33231. /**
  33232. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33233. */
  33234. onAfterRenderCameraObservable: Observable<Camera>;
  33235. private _onAfterRenderObserver;
  33236. /** Sets a function to be executed after rendering this scene */
  33237. afterRender: Nullable<() => void>;
  33238. /**
  33239. * An event triggered before animating the scene
  33240. */
  33241. onBeforeAnimationsObservable: Observable<Scene>;
  33242. /**
  33243. * An event triggered after animations processing
  33244. */
  33245. onAfterAnimationsObservable: Observable<Scene>;
  33246. /**
  33247. * An event triggered before draw calls are ready to be sent
  33248. */
  33249. onBeforeDrawPhaseObservable: Observable<Scene>;
  33250. /**
  33251. * An event triggered after draw calls have been sent
  33252. */
  33253. onAfterDrawPhaseObservable: Observable<Scene>;
  33254. /**
  33255. * An event triggered when the scene is ready
  33256. */
  33257. onReadyObservable: Observable<Scene>;
  33258. /**
  33259. * An event triggered before rendering a camera
  33260. */
  33261. onBeforeCameraRenderObservable: Observable<Camera>;
  33262. private _onBeforeCameraRenderObserver;
  33263. /** Sets a function to be executed before rendering a camera*/
  33264. beforeCameraRender: () => void;
  33265. /**
  33266. * An event triggered after rendering a camera
  33267. */
  33268. onAfterCameraRenderObservable: Observable<Camera>;
  33269. private _onAfterCameraRenderObserver;
  33270. /** Sets a function to be executed after rendering a camera*/
  33271. afterCameraRender: () => void;
  33272. /**
  33273. * An event triggered when active meshes evaluation is about to start
  33274. */
  33275. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33276. /**
  33277. * An event triggered when active meshes evaluation is done
  33278. */
  33279. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33280. /**
  33281. * An event triggered when particles rendering is about to start
  33282. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33283. */
  33284. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33285. /**
  33286. * An event triggered when particles rendering is done
  33287. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33288. */
  33289. onAfterParticlesRenderingObservable: Observable<Scene>;
  33290. /**
  33291. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33292. */
  33293. onDataLoadedObservable: Observable<Scene>;
  33294. /**
  33295. * An event triggered when a camera is created
  33296. */
  33297. onNewCameraAddedObservable: Observable<Camera>;
  33298. /**
  33299. * An event triggered when a camera is removed
  33300. */
  33301. onCameraRemovedObservable: Observable<Camera>;
  33302. /**
  33303. * An event triggered when a light is created
  33304. */
  33305. onNewLightAddedObservable: Observable<Light>;
  33306. /**
  33307. * An event triggered when a light is removed
  33308. */
  33309. onLightRemovedObservable: Observable<Light>;
  33310. /**
  33311. * An event triggered when a geometry is created
  33312. */
  33313. onNewGeometryAddedObservable: Observable<Geometry>;
  33314. /**
  33315. * An event triggered when a geometry is removed
  33316. */
  33317. onGeometryRemovedObservable: Observable<Geometry>;
  33318. /**
  33319. * An event triggered when a transform node is created
  33320. */
  33321. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33322. /**
  33323. * An event triggered when a transform node is removed
  33324. */
  33325. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33326. /**
  33327. * An event triggered when a mesh is created
  33328. */
  33329. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33330. /**
  33331. * An event triggered when a mesh is removed
  33332. */
  33333. onMeshRemovedObservable: Observable<AbstractMesh>;
  33334. /**
  33335. * An event triggered when a skeleton is created
  33336. */
  33337. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33338. /**
  33339. * An event triggered when a skeleton is removed
  33340. */
  33341. onSkeletonRemovedObservable: Observable<Skeleton>;
  33342. /**
  33343. * An event triggered when a material is created
  33344. */
  33345. onNewMaterialAddedObservable: Observable<Material>;
  33346. /**
  33347. * An event triggered when a material is removed
  33348. */
  33349. onMaterialRemovedObservable: Observable<Material>;
  33350. /**
  33351. * An event triggered when a texture is created
  33352. */
  33353. onNewTextureAddedObservable: Observable<BaseTexture>;
  33354. /**
  33355. * An event triggered when a texture is removed
  33356. */
  33357. onTextureRemovedObservable: Observable<BaseTexture>;
  33358. /**
  33359. * An event triggered when render targets are about to be rendered
  33360. * Can happen multiple times per frame.
  33361. */
  33362. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33363. /**
  33364. * An event triggered when render targets were rendered.
  33365. * Can happen multiple times per frame.
  33366. */
  33367. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33368. /**
  33369. * An event triggered before calculating deterministic simulation step
  33370. */
  33371. onBeforeStepObservable: Observable<Scene>;
  33372. /**
  33373. * An event triggered after calculating deterministic simulation step
  33374. */
  33375. onAfterStepObservable: Observable<Scene>;
  33376. /**
  33377. * An event triggered when the activeCamera property is updated
  33378. */
  33379. onActiveCameraChanged: Observable<Scene>;
  33380. /**
  33381. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33382. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33383. * 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)
  33384. */
  33385. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33386. /**
  33387. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33388. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33389. * 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)
  33390. */
  33391. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33392. /**
  33393. * This Observable will when a mesh has been imported into the scene.
  33394. */
  33395. onMeshImportedObservable: Observable<AbstractMesh>;
  33396. /**
  33397. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33398. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33399. */
  33400. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33401. /** @hidden */
  33402. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33403. /**
  33404. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33405. */
  33406. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33407. /**
  33408. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33409. */
  33410. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33411. /**
  33412. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33413. */
  33414. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33415. /** Callback called when a pointer move is detected */
  33416. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33417. /** Callback called when a pointer down is detected */
  33418. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33419. /** Callback called when a pointer up is detected */
  33420. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33421. /** Callback called when a pointer pick is detected */
  33422. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33423. /**
  33424. * 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).
  33425. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33426. */
  33427. onPrePointerObservable: Observable<PointerInfoPre>;
  33428. /**
  33429. * Observable event triggered each time an input event is received from the rendering canvas
  33430. */
  33431. onPointerObservable: Observable<PointerInfo>;
  33432. /**
  33433. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33434. */
  33435. readonly unTranslatedPointer: Vector2;
  33436. /**
  33437. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33438. */
  33439. static DragMovementThreshold: number;
  33440. /**
  33441. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33442. */
  33443. static LongPressDelay: number;
  33444. /**
  33445. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33446. */
  33447. static DoubleClickDelay: number;
  33448. /** If you need to check double click without raising a single click at first click, enable this flag */
  33449. static ExclusiveDoubleClickMode: boolean;
  33450. /** @hidden */
  33451. _mirroredCameraPosition: Nullable<Vector3>;
  33452. /**
  33453. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33454. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33455. */
  33456. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33457. /**
  33458. * Observable event triggered each time an keyboard event is received from the hosting window
  33459. */
  33460. onKeyboardObservable: Observable<KeyboardInfo>;
  33461. private _useRightHandedSystem;
  33462. /**
  33463. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33464. */
  33465. useRightHandedSystem: boolean;
  33466. private _timeAccumulator;
  33467. private _currentStepId;
  33468. private _currentInternalStep;
  33469. /**
  33470. * Sets the step Id used by deterministic lock step
  33471. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33472. * @param newStepId defines the step Id
  33473. */
  33474. setStepId(newStepId: number): void;
  33475. /**
  33476. * Gets the step Id used by deterministic lock step
  33477. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33478. * @returns the step Id
  33479. */
  33480. getStepId(): number;
  33481. /**
  33482. * Gets the internal step used by deterministic lock step
  33483. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33484. * @returns the internal step
  33485. */
  33486. getInternalStep(): number;
  33487. private _fogEnabled;
  33488. /**
  33489. * Gets or sets a boolean indicating if fog is enabled on this scene
  33490. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33491. * (Default is true)
  33492. */
  33493. fogEnabled: boolean;
  33494. private _fogMode;
  33495. /**
  33496. * Gets or sets the fog mode to use
  33497. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33498. * | mode | value |
  33499. * | --- | --- |
  33500. * | FOGMODE_NONE | 0 |
  33501. * | FOGMODE_EXP | 1 |
  33502. * | FOGMODE_EXP2 | 2 |
  33503. * | FOGMODE_LINEAR | 3 |
  33504. */
  33505. fogMode: number;
  33506. /**
  33507. * Gets or sets the fog color to use
  33508. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33509. * (Default is Color3(0.2, 0.2, 0.3))
  33510. */
  33511. fogColor: Color3;
  33512. /**
  33513. * Gets or sets the fog density to use
  33514. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33515. * (Default is 0.1)
  33516. */
  33517. fogDensity: number;
  33518. /**
  33519. * Gets or sets the fog start distance to use
  33520. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33521. * (Default is 0)
  33522. */
  33523. fogStart: number;
  33524. /**
  33525. * Gets or sets the fog end distance to use
  33526. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33527. * (Default is 1000)
  33528. */
  33529. fogEnd: number;
  33530. private _shadowsEnabled;
  33531. /**
  33532. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33533. */
  33534. shadowsEnabled: boolean;
  33535. private _lightsEnabled;
  33536. /**
  33537. * Gets or sets a boolean indicating if lights are enabled on this scene
  33538. */
  33539. lightsEnabled: boolean;
  33540. /** All of the active cameras added to this scene. */
  33541. activeCameras: Camera[];
  33542. /** @hidden */
  33543. _activeCamera: Nullable<Camera>;
  33544. /** Gets or sets the current active camera */
  33545. activeCamera: Nullable<Camera>;
  33546. private _defaultMaterial;
  33547. /** The default material used on meshes when no material is affected */
  33548. /** The default material used on meshes when no material is affected */
  33549. defaultMaterial: Material;
  33550. private _texturesEnabled;
  33551. /**
  33552. * Gets or sets a boolean indicating if textures are enabled on this scene
  33553. */
  33554. texturesEnabled: boolean;
  33555. /**
  33556. * Gets or sets a boolean indicating if particles are enabled on this scene
  33557. */
  33558. particlesEnabled: boolean;
  33559. /**
  33560. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33561. */
  33562. spritesEnabled: boolean;
  33563. private _skeletonsEnabled;
  33564. /**
  33565. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33566. */
  33567. skeletonsEnabled: boolean;
  33568. /**
  33569. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33570. */
  33571. lensFlaresEnabled: boolean;
  33572. /**
  33573. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33574. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33575. */
  33576. collisionsEnabled: boolean;
  33577. private _collisionCoordinator;
  33578. /** @hidden */
  33579. readonly collisionCoordinator: ICollisionCoordinator;
  33580. /**
  33581. * Defines the gravity applied to this scene (used only for collisions)
  33582. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33583. */
  33584. gravity: Vector3;
  33585. /**
  33586. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33587. */
  33588. postProcessesEnabled: boolean;
  33589. /**
  33590. * The list of postprocesses added to the scene
  33591. */
  33592. postProcesses: PostProcess[];
  33593. /**
  33594. * Gets the current postprocess manager
  33595. */
  33596. postProcessManager: PostProcessManager;
  33597. /**
  33598. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33599. */
  33600. renderTargetsEnabled: boolean;
  33601. /**
  33602. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33603. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33604. */
  33605. dumpNextRenderTargets: boolean;
  33606. /**
  33607. * The list of user defined render targets added to the scene
  33608. */
  33609. customRenderTargets: RenderTargetTexture[];
  33610. /**
  33611. * Defines if texture loading must be delayed
  33612. * If true, textures will only be loaded when they need to be rendered
  33613. */
  33614. useDelayedTextureLoading: boolean;
  33615. /**
  33616. * Gets the list of meshes imported to the scene through SceneLoader
  33617. */
  33618. importedMeshesFiles: String[];
  33619. /**
  33620. * Gets or sets a boolean indicating if probes are enabled on this scene
  33621. */
  33622. probesEnabled: boolean;
  33623. /**
  33624. * Gets or sets the current offline provider to use to store scene data
  33625. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33626. */
  33627. offlineProvider: IOfflineProvider;
  33628. /**
  33629. * Gets or sets the action manager associated with the scene
  33630. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33631. */
  33632. actionManager: AbstractActionManager;
  33633. private _meshesForIntersections;
  33634. /**
  33635. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33636. */
  33637. proceduralTexturesEnabled: boolean;
  33638. private _engine;
  33639. private _totalVertices;
  33640. /** @hidden */
  33641. _activeIndices: PerfCounter;
  33642. /** @hidden */
  33643. _activeParticles: PerfCounter;
  33644. /** @hidden */
  33645. _activeBones: PerfCounter;
  33646. private _animationRatio;
  33647. /** @hidden */
  33648. _animationTimeLast: number;
  33649. /** @hidden */
  33650. _animationTime: number;
  33651. /**
  33652. * Gets or sets a general scale for animation speed
  33653. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33654. */
  33655. animationTimeScale: number;
  33656. /** @hidden */
  33657. _cachedMaterial: Nullable<Material>;
  33658. /** @hidden */
  33659. _cachedEffect: Nullable<Effect>;
  33660. /** @hidden */
  33661. _cachedVisibility: Nullable<number>;
  33662. private _renderId;
  33663. private _frameId;
  33664. private _executeWhenReadyTimeoutId;
  33665. private _intermediateRendering;
  33666. private _viewUpdateFlag;
  33667. private _projectionUpdateFlag;
  33668. /** @hidden */
  33669. _toBeDisposed: Nullable<IDisposable>[];
  33670. private _activeRequests;
  33671. /** @hidden */
  33672. _pendingData: any[];
  33673. private _isDisposed;
  33674. /**
  33675. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33676. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33677. */
  33678. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33679. private _activeMeshes;
  33680. private _processedMaterials;
  33681. private _renderTargets;
  33682. /** @hidden */
  33683. _activeParticleSystems: SmartArray<IParticleSystem>;
  33684. private _activeSkeletons;
  33685. private _softwareSkinnedMeshes;
  33686. private _renderingManager;
  33687. /** @hidden */
  33688. _activeAnimatables: Animatable[];
  33689. private _transformMatrix;
  33690. private _sceneUbo;
  33691. /** @hidden */
  33692. _viewMatrix: Matrix;
  33693. private _projectionMatrix;
  33694. /** @hidden */
  33695. _forcedViewPosition: Nullable<Vector3>;
  33696. /** @hidden */
  33697. _frustumPlanes: Plane[];
  33698. /**
  33699. * Gets the list of frustum planes (built from the active camera)
  33700. */
  33701. readonly frustumPlanes: Plane[];
  33702. /**
  33703. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33704. * This is useful if there are more lights that the maximum simulteanous authorized
  33705. */
  33706. requireLightSorting: boolean;
  33707. /** @hidden */
  33708. readonly useMaterialMeshMap: boolean;
  33709. /** @hidden */
  33710. readonly useClonedMeshhMap: boolean;
  33711. private _externalData;
  33712. private _uid;
  33713. /**
  33714. * @hidden
  33715. * Backing store of defined scene components.
  33716. */
  33717. _components: ISceneComponent[];
  33718. /**
  33719. * @hidden
  33720. * Backing store of defined scene components.
  33721. */
  33722. _serializableComponents: ISceneSerializableComponent[];
  33723. /**
  33724. * List of components to register on the next registration step.
  33725. */
  33726. private _transientComponents;
  33727. /**
  33728. * Registers the transient components if needed.
  33729. */
  33730. private _registerTransientComponents;
  33731. /**
  33732. * @hidden
  33733. * Add a component to the scene.
  33734. * Note that the ccomponent could be registered on th next frame if this is called after
  33735. * the register component stage.
  33736. * @param component Defines the component to add to the scene
  33737. */
  33738. _addComponent(component: ISceneComponent): void;
  33739. /**
  33740. * @hidden
  33741. * Gets a component from the scene.
  33742. * @param name defines the name of the component to retrieve
  33743. * @returns the component or null if not present
  33744. */
  33745. _getComponent(name: string): Nullable<ISceneComponent>;
  33746. /**
  33747. * @hidden
  33748. * Defines the actions happening before camera updates.
  33749. */
  33750. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33751. /**
  33752. * @hidden
  33753. * Defines the actions happening before clear the canvas.
  33754. */
  33755. _beforeClearStage: Stage<SimpleStageAction>;
  33756. /**
  33757. * @hidden
  33758. * Defines the actions when collecting render targets for the frame.
  33759. */
  33760. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33761. /**
  33762. * @hidden
  33763. * Defines the actions happening for one camera in the frame.
  33764. */
  33765. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33766. /**
  33767. * @hidden
  33768. * Defines the actions happening during the per mesh ready checks.
  33769. */
  33770. _isReadyForMeshStage: Stage<MeshStageAction>;
  33771. /**
  33772. * @hidden
  33773. * Defines the actions happening before evaluate active mesh checks.
  33774. */
  33775. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33776. /**
  33777. * @hidden
  33778. * Defines the actions happening during the evaluate sub mesh checks.
  33779. */
  33780. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33781. /**
  33782. * @hidden
  33783. * Defines the actions happening during the active mesh stage.
  33784. */
  33785. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33786. /**
  33787. * @hidden
  33788. * Defines the actions happening during the per camera render target step.
  33789. */
  33790. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33791. /**
  33792. * @hidden
  33793. * Defines the actions happening just before the active camera is drawing.
  33794. */
  33795. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33796. /**
  33797. * @hidden
  33798. * Defines the actions happening just before a render target is drawing.
  33799. */
  33800. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33801. /**
  33802. * @hidden
  33803. * Defines the actions happening just before a rendering group is drawing.
  33804. */
  33805. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33806. /**
  33807. * @hidden
  33808. * Defines the actions happening just before a mesh is drawing.
  33809. */
  33810. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33811. /**
  33812. * @hidden
  33813. * Defines the actions happening just after a mesh has been drawn.
  33814. */
  33815. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33816. /**
  33817. * @hidden
  33818. * Defines the actions happening just after a rendering group has been drawn.
  33819. */
  33820. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33821. /**
  33822. * @hidden
  33823. * Defines the actions happening just after the active camera has been drawn.
  33824. */
  33825. _afterCameraDrawStage: Stage<CameraStageAction>;
  33826. /**
  33827. * @hidden
  33828. * Defines the actions happening just after a render target has been drawn.
  33829. */
  33830. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33831. /**
  33832. * @hidden
  33833. * Defines the actions happening just after rendering all cameras and computing intersections.
  33834. */
  33835. _afterRenderStage: Stage<SimpleStageAction>;
  33836. /**
  33837. * @hidden
  33838. * Defines the actions happening when a pointer move event happens.
  33839. */
  33840. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33841. /**
  33842. * @hidden
  33843. * Defines the actions happening when a pointer down event happens.
  33844. */
  33845. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33846. /**
  33847. * @hidden
  33848. * Defines the actions happening when a pointer up event happens.
  33849. */
  33850. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33851. /**
  33852. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33853. */
  33854. private geometriesByUniqueId;
  33855. /**
  33856. * Creates a new Scene
  33857. * @param engine defines the engine to use to render this scene
  33858. * @param options defines the scene options
  33859. */
  33860. constructor(engine: Engine, options?: SceneOptions);
  33861. /**
  33862. * Gets a string idenfifying the name of the class
  33863. * @returns "Scene" string
  33864. */
  33865. getClassName(): string;
  33866. private _defaultMeshCandidates;
  33867. /**
  33868. * @hidden
  33869. */
  33870. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33871. private _defaultSubMeshCandidates;
  33872. /**
  33873. * @hidden
  33874. */
  33875. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33876. /**
  33877. * Sets the default candidate providers for the scene.
  33878. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33879. * and getCollidingSubMeshCandidates to their default function
  33880. */
  33881. setDefaultCandidateProviders(): void;
  33882. /**
  33883. * Gets the mesh that is currently under the pointer
  33884. */
  33885. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33886. /**
  33887. * Gets or sets the current on-screen X position of the pointer
  33888. */
  33889. pointerX: number;
  33890. /**
  33891. * Gets or sets the current on-screen Y position of the pointer
  33892. */
  33893. pointerY: number;
  33894. /**
  33895. * Gets the cached material (ie. the latest rendered one)
  33896. * @returns the cached material
  33897. */
  33898. getCachedMaterial(): Nullable<Material>;
  33899. /**
  33900. * Gets the cached effect (ie. the latest rendered one)
  33901. * @returns the cached effect
  33902. */
  33903. getCachedEffect(): Nullable<Effect>;
  33904. /**
  33905. * Gets the cached visibility state (ie. the latest rendered one)
  33906. * @returns the cached visibility state
  33907. */
  33908. getCachedVisibility(): Nullable<number>;
  33909. /**
  33910. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33911. * @param material defines the current material
  33912. * @param effect defines the current effect
  33913. * @param visibility defines the current visibility state
  33914. * @returns true if one parameter is not cached
  33915. */
  33916. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33917. /**
  33918. * Gets the engine associated with the scene
  33919. * @returns an Engine
  33920. */
  33921. getEngine(): Engine;
  33922. /**
  33923. * Gets the total number of vertices rendered per frame
  33924. * @returns the total number of vertices rendered per frame
  33925. */
  33926. getTotalVertices(): number;
  33927. /**
  33928. * Gets the performance counter for total vertices
  33929. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33930. */
  33931. readonly totalVerticesPerfCounter: PerfCounter;
  33932. /**
  33933. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33934. * @returns the total number of active indices rendered per frame
  33935. */
  33936. getActiveIndices(): number;
  33937. /**
  33938. * Gets the performance counter for active indices
  33939. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33940. */
  33941. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33942. /**
  33943. * Gets the total number of active particles rendered per frame
  33944. * @returns the total number of active particles rendered per frame
  33945. */
  33946. getActiveParticles(): number;
  33947. /**
  33948. * Gets the performance counter for active particles
  33949. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33950. */
  33951. readonly activeParticlesPerfCounter: PerfCounter;
  33952. /**
  33953. * Gets the total number of active bones rendered per frame
  33954. * @returns the total number of active bones rendered per frame
  33955. */
  33956. getActiveBones(): number;
  33957. /**
  33958. * Gets the performance counter for active bones
  33959. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33960. */
  33961. readonly activeBonesPerfCounter: PerfCounter;
  33962. /**
  33963. * Gets the array of active meshes
  33964. * @returns an array of AbstractMesh
  33965. */
  33966. getActiveMeshes(): SmartArray<AbstractMesh>;
  33967. /**
  33968. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33969. * @returns a number
  33970. */
  33971. getAnimationRatio(): number;
  33972. /**
  33973. * Gets an unique Id for the current render phase
  33974. * @returns a number
  33975. */
  33976. getRenderId(): number;
  33977. /**
  33978. * Gets an unique Id for the current frame
  33979. * @returns a number
  33980. */
  33981. getFrameId(): number;
  33982. /** Call this function if you want to manually increment the render Id*/
  33983. incrementRenderId(): void;
  33984. private _createUbo;
  33985. /**
  33986. * Use this method to simulate a pointer move on a mesh
  33987. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33988. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33989. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33990. * @returns the current scene
  33991. */
  33992. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33993. /**
  33994. * Use this method to simulate a pointer down on a mesh
  33995. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33996. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33997. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33998. * @returns the current scene
  33999. */
  34000. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34001. /**
  34002. * Use this method to simulate a pointer up on a mesh
  34003. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34004. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34005. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34006. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34007. * @returns the current scene
  34008. */
  34009. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34010. /**
  34011. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34012. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34013. * @returns true if the pointer was captured
  34014. */
  34015. isPointerCaptured(pointerId?: number): boolean;
  34016. /**
  34017. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34018. * @param attachUp defines if you want to attach events to pointerup
  34019. * @param attachDown defines if you want to attach events to pointerdown
  34020. * @param attachMove defines if you want to attach events to pointermove
  34021. */
  34022. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34023. /** Detaches all event handlers*/
  34024. detachControl(): void;
  34025. /**
  34026. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34027. * Delay loaded resources are not taking in account
  34028. * @return true if all required resources are ready
  34029. */
  34030. isReady(): boolean;
  34031. /** Resets all cached information relative to material (including effect and visibility) */
  34032. resetCachedMaterial(): void;
  34033. /**
  34034. * Registers a function to be called before every frame render
  34035. * @param func defines the function to register
  34036. */
  34037. registerBeforeRender(func: () => void): void;
  34038. /**
  34039. * Unregisters a function called before every frame render
  34040. * @param func defines the function to unregister
  34041. */
  34042. unregisterBeforeRender(func: () => void): void;
  34043. /**
  34044. * Registers a function to be called after every frame render
  34045. * @param func defines the function to register
  34046. */
  34047. registerAfterRender(func: () => void): void;
  34048. /**
  34049. * Unregisters a function called after every frame render
  34050. * @param func defines the function to unregister
  34051. */
  34052. unregisterAfterRender(func: () => void): void;
  34053. private _executeOnceBeforeRender;
  34054. /**
  34055. * The provided function will run before render once and will be disposed afterwards.
  34056. * A timeout delay can be provided so that the function will be executed in N ms.
  34057. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34058. * @param func The function to be executed.
  34059. * @param timeout optional delay in ms
  34060. */
  34061. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34062. /** @hidden */
  34063. _addPendingData(data: any): void;
  34064. /** @hidden */
  34065. _removePendingData(data: any): void;
  34066. /**
  34067. * Returns the number of items waiting to be loaded
  34068. * @returns the number of items waiting to be loaded
  34069. */
  34070. getWaitingItemsCount(): number;
  34071. /**
  34072. * Returns a boolean indicating if the scene is still loading data
  34073. */
  34074. readonly isLoading: boolean;
  34075. /**
  34076. * Registers a function to be executed when the scene is ready
  34077. * @param {Function} func - the function to be executed
  34078. */
  34079. executeWhenReady(func: () => void): void;
  34080. /**
  34081. * Returns a promise that resolves when the scene is ready
  34082. * @returns A promise that resolves when the scene is ready
  34083. */
  34084. whenReadyAsync(): Promise<void>;
  34085. /** @hidden */
  34086. _checkIsReady(): void;
  34087. /**
  34088. * Gets all animatable attached to the scene
  34089. */
  34090. readonly animatables: Animatable[];
  34091. /**
  34092. * Resets the last animation time frame.
  34093. * Useful to override when animations start running when loading a scene for the first time.
  34094. */
  34095. resetLastAnimationTimeFrame(): void;
  34096. /**
  34097. * Gets the current view matrix
  34098. * @returns a Matrix
  34099. */
  34100. getViewMatrix(): Matrix;
  34101. /**
  34102. * Gets the current projection matrix
  34103. * @returns a Matrix
  34104. */
  34105. getProjectionMatrix(): Matrix;
  34106. /**
  34107. * Gets the current transform matrix
  34108. * @returns a Matrix made of View * Projection
  34109. */
  34110. getTransformMatrix(): Matrix;
  34111. /**
  34112. * Sets the current transform matrix
  34113. * @param viewL defines the View matrix to use
  34114. * @param projectionL defines the Projection matrix to use
  34115. * @param viewR defines the right View matrix to use (if provided)
  34116. * @param projectionR defines the right Projection matrix to use (if provided)
  34117. */
  34118. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34119. /**
  34120. * Gets the uniform buffer used to store scene data
  34121. * @returns a UniformBuffer
  34122. */
  34123. getSceneUniformBuffer(): UniformBuffer;
  34124. /**
  34125. * Gets an unique (relatively to the current scene) Id
  34126. * @returns an unique number for the scene
  34127. */
  34128. getUniqueId(): number;
  34129. /**
  34130. * Add a mesh to the list of scene's meshes
  34131. * @param newMesh defines the mesh to add
  34132. * @param recursive if all child meshes should also be added to the scene
  34133. */
  34134. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34135. /**
  34136. * Remove a mesh for the list of scene's meshes
  34137. * @param toRemove defines the mesh to remove
  34138. * @param recursive if all child meshes should also be removed from the scene
  34139. * @returns the index where the mesh was in the mesh list
  34140. */
  34141. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34142. /**
  34143. * Add a transform node to the list of scene's transform nodes
  34144. * @param newTransformNode defines the transform node to add
  34145. */
  34146. addTransformNode(newTransformNode: TransformNode): void;
  34147. /**
  34148. * Remove a transform node for the list of scene's transform nodes
  34149. * @param toRemove defines the transform node to remove
  34150. * @returns the index where the transform node was in the transform node list
  34151. */
  34152. removeTransformNode(toRemove: TransformNode): number;
  34153. /**
  34154. * Remove a skeleton for the list of scene's skeletons
  34155. * @param toRemove defines the skeleton to remove
  34156. * @returns the index where the skeleton was in the skeleton list
  34157. */
  34158. removeSkeleton(toRemove: Skeleton): number;
  34159. /**
  34160. * Remove a morph target for the list of scene's morph targets
  34161. * @param toRemove defines the morph target to remove
  34162. * @returns the index where the morph target was in the morph target list
  34163. */
  34164. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34165. /**
  34166. * Remove a light for the list of scene's lights
  34167. * @param toRemove defines the light to remove
  34168. * @returns the index where the light was in the light list
  34169. */
  34170. removeLight(toRemove: Light): number;
  34171. /**
  34172. * Remove a camera for the list of scene's cameras
  34173. * @param toRemove defines the camera to remove
  34174. * @returns the index where the camera was in the camera list
  34175. */
  34176. removeCamera(toRemove: Camera): number;
  34177. /**
  34178. * Remove a particle system for the list of scene's particle systems
  34179. * @param toRemove defines the particle system to remove
  34180. * @returns the index where the particle system was in the particle system list
  34181. */
  34182. removeParticleSystem(toRemove: IParticleSystem): number;
  34183. /**
  34184. * Remove a animation for the list of scene's animations
  34185. * @param toRemove defines the animation to remove
  34186. * @returns the index where the animation was in the animation list
  34187. */
  34188. removeAnimation(toRemove: Animation): number;
  34189. /**
  34190. * Will stop the animation of the given target
  34191. * @param target - the target
  34192. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34193. * @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)
  34194. */
  34195. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34196. /**
  34197. * Removes the given animation group from this scene.
  34198. * @param toRemove The animation group to remove
  34199. * @returns The index of the removed animation group
  34200. */
  34201. removeAnimationGroup(toRemove: AnimationGroup): number;
  34202. /**
  34203. * Removes the given multi-material from this scene.
  34204. * @param toRemove The multi-material to remove
  34205. * @returns The index of the removed multi-material
  34206. */
  34207. removeMultiMaterial(toRemove: MultiMaterial): number;
  34208. /**
  34209. * Removes the given material from this scene.
  34210. * @param toRemove The material to remove
  34211. * @returns The index of the removed material
  34212. */
  34213. removeMaterial(toRemove: Material): number;
  34214. /**
  34215. * Removes the given action manager from this scene.
  34216. * @param toRemove The action manager to remove
  34217. * @returns The index of the removed action manager
  34218. */
  34219. removeActionManager(toRemove: AbstractActionManager): number;
  34220. /**
  34221. * Removes the given texture from this scene.
  34222. * @param toRemove The texture to remove
  34223. * @returns The index of the removed texture
  34224. */
  34225. removeTexture(toRemove: BaseTexture): number;
  34226. /**
  34227. * Adds the given light to this scene
  34228. * @param newLight The light to add
  34229. */
  34230. addLight(newLight: Light): void;
  34231. /**
  34232. * Sorts the list list based on light priorities
  34233. */
  34234. sortLightsByPriority(): void;
  34235. /**
  34236. * Adds the given camera to this scene
  34237. * @param newCamera The camera to add
  34238. */
  34239. addCamera(newCamera: Camera): void;
  34240. /**
  34241. * Adds the given skeleton to this scene
  34242. * @param newSkeleton The skeleton to add
  34243. */
  34244. addSkeleton(newSkeleton: Skeleton): void;
  34245. /**
  34246. * Adds the given particle system to this scene
  34247. * @param newParticleSystem The particle system to add
  34248. */
  34249. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34250. /**
  34251. * Adds the given animation to this scene
  34252. * @param newAnimation The animation to add
  34253. */
  34254. addAnimation(newAnimation: Animation): void;
  34255. /**
  34256. * Adds the given animation group to this scene.
  34257. * @param newAnimationGroup The animation group to add
  34258. */
  34259. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34260. /**
  34261. * Adds the given multi-material to this scene
  34262. * @param newMultiMaterial The multi-material to add
  34263. */
  34264. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34265. /**
  34266. * Adds the given material to this scene
  34267. * @param newMaterial The material to add
  34268. */
  34269. addMaterial(newMaterial: Material): void;
  34270. /**
  34271. * Adds the given morph target to this scene
  34272. * @param newMorphTargetManager The morph target to add
  34273. */
  34274. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34275. /**
  34276. * Adds the given geometry to this scene
  34277. * @param newGeometry The geometry to add
  34278. */
  34279. addGeometry(newGeometry: Geometry): void;
  34280. /**
  34281. * Adds the given action manager to this scene
  34282. * @param newActionManager The action manager to add
  34283. */
  34284. addActionManager(newActionManager: AbstractActionManager): void;
  34285. /**
  34286. * Adds the given texture to this scene.
  34287. * @param newTexture The texture to add
  34288. */
  34289. addTexture(newTexture: BaseTexture): void;
  34290. /**
  34291. * Switch active camera
  34292. * @param newCamera defines the new active camera
  34293. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34294. */
  34295. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34296. /**
  34297. * sets the active camera of the scene using its ID
  34298. * @param id defines the camera's ID
  34299. * @return the new active camera or null if none found.
  34300. */
  34301. setActiveCameraByID(id: string): Nullable<Camera>;
  34302. /**
  34303. * sets the active camera of the scene using its name
  34304. * @param name defines the camera's name
  34305. * @returns the new active camera or null if none found.
  34306. */
  34307. setActiveCameraByName(name: string): Nullable<Camera>;
  34308. /**
  34309. * get an animation group using its name
  34310. * @param name defines the material's name
  34311. * @return the animation group or null if none found.
  34312. */
  34313. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34314. /**
  34315. * Get a material using its unique id
  34316. * @param uniqueId defines the material's unique id
  34317. * @return the material or null if none found.
  34318. */
  34319. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34320. /**
  34321. * get a material using its id
  34322. * @param id defines the material's ID
  34323. * @return the material or null if none found.
  34324. */
  34325. getMaterialByID(id: string): Nullable<Material>;
  34326. /**
  34327. * Gets a the last added material using a given id
  34328. * @param id defines the material's ID
  34329. * @return the last material with the given id or null if none found.
  34330. */
  34331. getLastMaterialByID(id: string): Nullable<Material>;
  34332. /**
  34333. * Gets a material using its name
  34334. * @param name defines the material's name
  34335. * @return the material or null if none found.
  34336. */
  34337. getMaterialByName(name: string): Nullable<Material>;
  34338. /**
  34339. * Get a texture using its unique id
  34340. * @param uniqueId defines the texture's unique id
  34341. * @return the texture or null if none found.
  34342. */
  34343. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34344. /**
  34345. * Gets a camera using its id
  34346. * @param id defines the id to look for
  34347. * @returns the camera or null if not found
  34348. */
  34349. getCameraByID(id: string): Nullable<Camera>;
  34350. /**
  34351. * Gets a camera using its unique id
  34352. * @param uniqueId defines the unique id to look for
  34353. * @returns the camera or null if not found
  34354. */
  34355. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34356. /**
  34357. * Gets a camera using its name
  34358. * @param name defines the camera's name
  34359. * @return the camera or null if none found.
  34360. */
  34361. getCameraByName(name: string): Nullable<Camera>;
  34362. /**
  34363. * Gets a bone using its id
  34364. * @param id defines the bone's id
  34365. * @return the bone or null if not found
  34366. */
  34367. getBoneByID(id: string): Nullable<Bone>;
  34368. /**
  34369. * Gets a bone using its id
  34370. * @param name defines the bone's name
  34371. * @return the bone or null if not found
  34372. */
  34373. getBoneByName(name: string): Nullable<Bone>;
  34374. /**
  34375. * Gets a light node using its name
  34376. * @param name defines the the light's name
  34377. * @return the light or null if none found.
  34378. */
  34379. getLightByName(name: string): Nullable<Light>;
  34380. /**
  34381. * Gets a light node using its id
  34382. * @param id defines the light's id
  34383. * @return the light or null if none found.
  34384. */
  34385. getLightByID(id: string): Nullable<Light>;
  34386. /**
  34387. * Gets a light node using its scene-generated unique ID
  34388. * @param uniqueId defines the light's unique id
  34389. * @return the light or null if none found.
  34390. */
  34391. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34392. /**
  34393. * Gets a particle system by id
  34394. * @param id defines the particle system id
  34395. * @return the corresponding system or null if none found
  34396. */
  34397. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34398. /**
  34399. * Gets a geometry using its ID
  34400. * @param id defines the geometry's id
  34401. * @return the geometry or null if none found.
  34402. */
  34403. getGeometryByID(id: string): Nullable<Geometry>;
  34404. private _getGeometryByUniqueID;
  34405. /**
  34406. * Add a new geometry to this scene
  34407. * @param geometry defines the geometry to be added to the scene.
  34408. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34409. * @return a boolean defining if the geometry was added or not
  34410. */
  34411. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34412. /**
  34413. * Removes an existing geometry
  34414. * @param geometry defines the geometry to be removed from the scene
  34415. * @return a boolean defining if the geometry was removed or not
  34416. */
  34417. removeGeometry(geometry: Geometry): boolean;
  34418. /**
  34419. * Gets the list of geometries attached to the scene
  34420. * @returns an array of Geometry
  34421. */
  34422. getGeometries(): Geometry[];
  34423. /**
  34424. * Gets the first added mesh found of a given ID
  34425. * @param id defines the id to search for
  34426. * @return the mesh found or null if not found at all
  34427. */
  34428. getMeshByID(id: string): Nullable<AbstractMesh>;
  34429. /**
  34430. * Gets a list of meshes using their id
  34431. * @param id defines the id to search for
  34432. * @returns a list of meshes
  34433. */
  34434. getMeshesByID(id: string): Array<AbstractMesh>;
  34435. /**
  34436. * Gets the first added transform node found of a given ID
  34437. * @param id defines the id to search for
  34438. * @return the found transform node or null if not found at all.
  34439. */
  34440. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34441. /**
  34442. * Gets a transform node with its auto-generated unique id
  34443. * @param uniqueId efines the unique id to search for
  34444. * @return the found transform node or null if not found at all.
  34445. */
  34446. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34447. /**
  34448. * Gets a list of transform nodes using their id
  34449. * @param id defines the id to search for
  34450. * @returns a list of transform nodes
  34451. */
  34452. getTransformNodesByID(id: string): Array<TransformNode>;
  34453. /**
  34454. * Gets a mesh with its auto-generated unique id
  34455. * @param uniqueId defines the unique id to search for
  34456. * @return the found mesh or null if not found at all.
  34457. */
  34458. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34459. /**
  34460. * Gets a the last added mesh using a given id
  34461. * @param id defines the id to search for
  34462. * @return the found mesh or null if not found at all.
  34463. */
  34464. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34465. /**
  34466. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34467. * @param id defines the id to search for
  34468. * @return the found node or null if not found at all
  34469. */
  34470. getLastEntryByID(id: string): Nullable<Node>;
  34471. /**
  34472. * Gets a node (Mesh, Camera, Light) using a given id
  34473. * @param id defines the id to search for
  34474. * @return the found node or null if not found at all
  34475. */
  34476. getNodeByID(id: string): Nullable<Node>;
  34477. /**
  34478. * Gets a node (Mesh, Camera, Light) using a given name
  34479. * @param name defines the name to search for
  34480. * @return the found node or null if not found at all.
  34481. */
  34482. getNodeByName(name: string): Nullable<Node>;
  34483. /**
  34484. * Gets a mesh using a given name
  34485. * @param name defines the name to search for
  34486. * @return the found mesh or null if not found at all.
  34487. */
  34488. getMeshByName(name: string): Nullable<AbstractMesh>;
  34489. /**
  34490. * Gets a transform node using a given name
  34491. * @param name defines the name to search for
  34492. * @return the found transform node or null if not found at all.
  34493. */
  34494. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34495. /**
  34496. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34497. * @param id defines the id to search for
  34498. * @return the found skeleton or null if not found at all.
  34499. */
  34500. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34501. /**
  34502. * Gets a skeleton using a given auto generated unique id
  34503. * @param uniqueId defines the unique id to search for
  34504. * @return the found skeleton or null if not found at all.
  34505. */
  34506. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34507. /**
  34508. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34509. * @param id defines the id to search for
  34510. * @return the found skeleton or null if not found at all.
  34511. */
  34512. getSkeletonById(id: string): Nullable<Skeleton>;
  34513. /**
  34514. * Gets a skeleton using a given name
  34515. * @param name defines the name to search for
  34516. * @return the found skeleton or null if not found at all.
  34517. */
  34518. getSkeletonByName(name: string): Nullable<Skeleton>;
  34519. /**
  34520. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34521. * @param id defines the id to search for
  34522. * @return the found morph target manager or null if not found at all.
  34523. */
  34524. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34525. /**
  34526. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34527. * @param id defines the id to search for
  34528. * @return the found morph target or null if not found at all.
  34529. */
  34530. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34531. /**
  34532. * Gets a boolean indicating if the given mesh is active
  34533. * @param mesh defines the mesh to look for
  34534. * @returns true if the mesh is in the active list
  34535. */
  34536. isActiveMesh(mesh: AbstractMesh): boolean;
  34537. /**
  34538. * Return a unique id as a string which can serve as an identifier for the scene
  34539. */
  34540. readonly uid: string;
  34541. /**
  34542. * Add an externaly attached data from its key.
  34543. * This method call will fail and return false, if such key already exists.
  34544. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34545. * @param key the unique key that identifies the data
  34546. * @param data the data object to associate to the key for this Engine instance
  34547. * @return true if no such key were already present and the data was added successfully, false otherwise
  34548. */
  34549. addExternalData<T>(key: string, data: T): boolean;
  34550. /**
  34551. * Get an externaly attached data from its key
  34552. * @param key the unique key that identifies the data
  34553. * @return the associated data, if present (can be null), or undefined if not present
  34554. */
  34555. getExternalData<T>(key: string): Nullable<T>;
  34556. /**
  34557. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34558. * @param key the unique key that identifies the data
  34559. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34560. * @return the associated data, can be null if the factory returned null.
  34561. */
  34562. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34563. /**
  34564. * Remove an externaly attached data from the Engine instance
  34565. * @param key the unique key that identifies the data
  34566. * @return true if the data was successfully removed, false if it doesn't exist
  34567. */
  34568. removeExternalData(key: string): boolean;
  34569. private _evaluateSubMesh;
  34570. /**
  34571. * Clear the processed materials smart array preventing retention point in material dispose.
  34572. */
  34573. freeProcessedMaterials(): void;
  34574. private _preventFreeActiveMeshesAndRenderingGroups;
  34575. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34576. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34577. * when disposing several meshes in a row or a hierarchy of meshes.
  34578. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34579. */
  34580. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34581. /**
  34582. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34583. */
  34584. freeActiveMeshes(): void;
  34585. /**
  34586. * Clear the info related to rendering groups preventing retention points during dispose.
  34587. */
  34588. freeRenderingGroups(): void;
  34589. /** @hidden */
  34590. _isInIntermediateRendering(): boolean;
  34591. /**
  34592. * Lambda returning the list of potentially active meshes.
  34593. */
  34594. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34595. /**
  34596. * Lambda returning the list of potentially active sub meshes.
  34597. */
  34598. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34599. /**
  34600. * Lambda returning the list of potentially intersecting sub meshes.
  34601. */
  34602. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34603. /**
  34604. * Lambda returning the list of potentially colliding sub meshes.
  34605. */
  34606. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34607. private _activeMeshesFrozen;
  34608. /**
  34609. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34610. * @returns the current scene
  34611. */
  34612. freezeActiveMeshes(): Scene;
  34613. /**
  34614. * Use this function to restart evaluating active meshes on every frame
  34615. * @returns the current scene
  34616. */
  34617. unfreezeActiveMeshes(): Scene;
  34618. private _evaluateActiveMeshes;
  34619. private _activeMesh;
  34620. /**
  34621. * Update the transform matrix to update from the current active camera
  34622. * @param force defines a boolean used to force the update even if cache is up to date
  34623. */
  34624. updateTransformMatrix(force?: boolean): void;
  34625. private _bindFrameBuffer;
  34626. /** @hidden */
  34627. _allowPostProcessClearColor: boolean;
  34628. /** @hidden */
  34629. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34630. private _processSubCameras;
  34631. private _checkIntersections;
  34632. /** @hidden */
  34633. _advancePhysicsEngineStep(step: number): void;
  34634. /**
  34635. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34636. */
  34637. getDeterministicFrameTime: () => number;
  34638. /** @hidden */
  34639. _animate(): void;
  34640. /** Execute all animations (for a frame) */
  34641. animate(): void;
  34642. /**
  34643. * Render the scene
  34644. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34645. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34646. */
  34647. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34648. /**
  34649. * Freeze all materials
  34650. * A frozen material will not be updatable but should be faster to render
  34651. */
  34652. freezeMaterials(): void;
  34653. /**
  34654. * Unfreeze all materials
  34655. * A frozen material will not be updatable but should be faster to render
  34656. */
  34657. unfreezeMaterials(): void;
  34658. /**
  34659. * Releases all held ressources
  34660. */
  34661. dispose(): void;
  34662. /**
  34663. * Gets if the scene is already disposed
  34664. */
  34665. readonly isDisposed: boolean;
  34666. /**
  34667. * Call this function to reduce memory footprint of the scene.
  34668. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34669. */
  34670. clearCachedVertexData(): void;
  34671. /**
  34672. * This function will remove the local cached buffer data from texture.
  34673. * It will save memory but will prevent the texture from being rebuilt
  34674. */
  34675. cleanCachedTextureBuffer(): void;
  34676. /**
  34677. * Get the world extend vectors with an optional filter
  34678. *
  34679. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34680. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34681. */
  34682. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34683. min: Vector3;
  34684. max: Vector3;
  34685. };
  34686. /**
  34687. * Creates a ray that can be used to pick in the scene
  34688. * @param x defines the x coordinate of the origin (on-screen)
  34689. * @param y defines the y coordinate of the origin (on-screen)
  34690. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34691. * @param camera defines the camera to use for the picking
  34692. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34693. * @returns a Ray
  34694. */
  34695. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34696. /**
  34697. * Creates a ray that can be used to pick in the scene
  34698. * @param x defines the x coordinate of the origin (on-screen)
  34699. * @param y defines the y coordinate of the origin (on-screen)
  34700. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34701. * @param result defines the ray where to store the picking ray
  34702. * @param camera defines the camera to use for the picking
  34703. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34704. * @returns the current scene
  34705. */
  34706. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34707. /**
  34708. * Creates a ray that can be used to pick in the scene
  34709. * @param x defines the x coordinate of the origin (on-screen)
  34710. * @param y defines the y coordinate of the origin (on-screen)
  34711. * @param camera defines the camera to use for the picking
  34712. * @returns a Ray
  34713. */
  34714. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34715. /**
  34716. * Creates a ray that can be used to pick in the scene
  34717. * @param x defines the x coordinate of the origin (on-screen)
  34718. * @param y defines the y coordinate of the origin (on-screen)
  34719. * @param result defines the ray where to store the picking ray
  34720. * @param camera defines the camera to use for the picking
  34721. * @returns the current scene
  34722. */
  34723. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34724. /** Launch a ray to try to pick a mesh in the scene
  34725. * @param x position on screen
  34726. * @param y position on screen
  34727. * @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
  34728. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34729. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34730. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34731. * @returns a PickingInfo
  34732. */
  34733. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34734. /** Use the given ray to pick a mesh in the scene
  34735. * @param ray The ray to use to pick meshes
  34736. * @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
  34737. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34738. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34739. * @returns a PickingInfo
  34740. */
  34741. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34742. /**
  34743. * Launch a ray to try to pick a mesh in the scene
  34744. * @param x X position on screen
  34745. * @param y Y position on screen
  34746. * @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
  34747. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34748. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34749. * @returns an array of PickingInfo
  34750. */
  34751. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34752. /**
  34753. * Launch a ray to try to pick a mesh in the scene
  34754. * @param ray Ray to use
  34755. * @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
  34756. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34757. * @returns an array of PickingInfo
  34758. */
  34759. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34760. /**
  34761. * Force the value of meshUnderPointer
  34762. * @param mesh defines the mesh to use
  34763. */
  34764. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34765. /**
  34766. * Gets the mesh under the pointer
  34767. * @returns a Mesh or null if no mesh is under the pointer
  34768. */
  34769. getPointerOverMesh(): Nullable<AbstractMesh>;
  34770. /** @hidden */
  34771. _rebuildGeometries(): void;
  34772. /** @hidden */
  34773. _rebuildTextures(): void;
  34774. private _getByTags;
  34775. /**
  34776. * Get a list of meshes by tags
  34777. * @param tagsQuery defines the tags query to use
  34778. * @param forEach defines a predicate used to filter results
  34779. * @returns an array of Mesh
  34780. */
  34781. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34782. /**
  34783. * Get a list of cameras by tags
  34784. * @param tagsQuery defines the tags query to use
  34785. * @param forEach defines a predicate used to filter results
  34786. * @returns an array of Camera
  34787. */
  34788. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34789. /**
  34790. * Get a list of lights by tags
  34791. * @param tagsQuery defines the tags query to use
  34792. * @param forEach defines a predicate used to filter results
  34793. * @returns an array of Light
  34794. */
  34795. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34796. /**
  34797. * Get a list of materials by tags
  34798. * @param tagsQuery defines the tags query to use
  34799. * @param forEach defines a predicate used to filter results
  34800. * @returns an array of Material
  34801. */
  34802. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34803. /**
  34804. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34805. * This allowed control for front to back rendering or reversly depending of the special needs.
  34806. *
  34807. * @param renderingGroupId The rendering group id corresponding to its index
  34808. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34809. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34810. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34811. */
  34812. 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;
  34813. /**
  34814. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34815. *
  34816. * @param renderingGroupId The rendering group id corresponding to its index
  34817. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34818. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34819. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34820. */
  34821. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34822. /**
  34823. * Gets the current auto clear configuration for one rendering group of the rendering
  34824. * manager.
  34825. * @param index the rendering group index to get the information for
  34826. * @returns The auto clear setup for the requested rendering group
  34827. */
  34828. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34829. private _blockMaterialDirtyMechanism;
  34830. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34831. blockMaterialDirtyMechanism: boolean;
  34832. /**
  34833. * Will flag all materials as dirty to trigger new shader compilation
  34834. * @param flag defines the flag used to specify which material part must be marked as dirty
  34835. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34836. */
  34837. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34838. /** @hidden */
  34839. _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;
  34840. /** @hidden */
  34841. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34842. }
  34843. }
  34844. declare module BABYLON {
  34845. /**
  34846. * Set of assets to keep when moving a scene into an asset container.
  34847. */
  34848. export class KeepAssets extends AbstractScene {
  34849. }
  34850. /**
  34851. * Container with a set of assets that can be added or removed from a scene.
  34852. */
  34853. export class AssetContainer extends AbstractScene {
  34854. /**
  34855. * The scene the AssetContainer belongs to.
  34856. */
  34857. scene: Scene;
  34858. /**
  34859. * Instantiates an AssetContainer.
  34860. * @param scene The scene the AssetContainer belongs to.
  34861. */
  34862. constructor(scene: Scene);
  34863. /**
  34864. * Adds all the assets from the container to the scene.
  34865. */
  34866. addAllToScene(): void;
  34867. /**
  34868. * Removes all the assets in the container from the scene
  34869. */
  34870. removeAllFromScene(): void;
  34871. /**
  34872. * Disposes all the assets in the container
  34873. */
  34874. dispose(): void;
  34875. private _moveAssets;
  34876. /**
  34877. * Removes all the assets contained in the scene and adds them to the container.
  34878. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34879. */
  34880. moveAllFromScene(keepAssets?: KeepAssets): void;
  34881. /**
  34882. * 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.
  34883. * @returns the root mesh
  34884. */
  34885. createRootMesh(): Mesh;
  34886. }
  34887. }
  34888. declare module BABYLON {
  34889. /**
  34890. * Defines how the parser contract is defined.
  34891. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34892. */
  34893. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34894. /**
  34895. * Defines how the individual parser contract is defined.
  34896. * These parser can parse an individual asset
  34897. */
  34898. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34899. /**
  34900. * Base class of the scene acting as a container for the different elements composing a scene.
  34901. * This class is dynamically extended by the different components of the scene increasing
  34902. * flexibility and reducing coupling
  34903. */
  34904. export abstract class AbstractScene {
  34905. /**
  34906. * Stores the list of available parsers in the application.
  34907. */
  34908. private static _BabylonFileParsers;
  34909. /**
  34910. * Stores the list of available individual parsers in the application.
  34911. */
  34912. private static _IndividualBabylonFileParsers;
  34913. /**
  34914. * Adds a parser in the list of available ones
  34915. * @param name Defines the name of the parser
  34916. * @param parser Defines the parser to add
  34917. */
  34918. static AddParser(name: string, parser: BabylonFileParser): void;
  34919. /**
  34920. * Gets a general parser from the list of avaialble ones
  34921. * @param name Defines the name of the parser
  34922. * @returns the requested parser or null
  34923. */
  34924. static GetParser(name: string): Nullable<BabylonFileParser>;
  34925. /**
  34926. * Adds n individual parser in the list of available ones
  34927. * @param name Defines the name of the parser
  34928. * @param parser Defines the parser to add
  34929. */
  34930. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34931. /**
  34932. * Gets an individual parser from the list of avaialble ones
  34933. * @param name Defines the name of the parser
  34934. * @returns the requested parser or null
  34935. */
  34936. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34937. /**
  34938. * Parser json data and populate both a scene and its associated container object
  34939. * @param jsonData Defines the data to parse
  34940. * @param scene Defines the scene to parse the data for
  34941. * @param container Defines the container attached to the parsing sequence
  34942. * @param rootUrl Defines the root url of the data
  34943. */
  34944. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34945. /**
  34946. * Gets the list of root nodes (ie. nodes with no parent)
  34947. */
  34948. rootNodes: Node[];
  34949. /** All of the cameras added to this scene
  34950. * @see http://doc.babylonjs.com/babylon101/cameras
  34951. */
  34952. cameras: Camera[];
  34953. /**
  34954. * All of the lights added to this scene
  34955. * @see http://doc.babylonjs.com/babylon101/lights
  34956. */
  34957. lights: Light[];
  34958. /**
  34959. * All of the (abstract) meshes added to this scene
  34960. */
  34961. meshes: AbstractMesh[];
  34962. /**
  34963. * The list of skeletons added to the scene
  34964. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34965. */
  34966. skeletons: Skeleton[];
  34967. /**
  34968. * All of the particle systems added to this scene
  34969. * @see http://doc.babylonjs.com/babylon101/particles
  34970. */
  34971. particleSystems: IParticleSystem[];
  34972. /**
  34973. * Gets a list of Animations associated with the scene
  34974. */
  34975. animations: Animation[];
  34976. /**
  34977. * All of the animation groups added to this scene
  34978. * @see http://doc.babylonjs.com/how_to/group
  34979. */
  34980. animationGroups: AnimationGroup[];
  34981. /**
  34982. * All of the multi-materials added to this scene
  34983. * @see http://doc.babylonjs.com/how_to/multi_materials
  34984. */
  34985. multiMaterials: MultiMaterial[];
  34986. /**
  34987. * All of the materials added to this scene
  34988. * In the context of a Scene, it is not supposed to be modified manually.
  34989. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34990. * Note also that the order of the Material wihin the array is not significant and might change.
  34991. * @see http://doc.babylonjs.com/babylon101/materials
  34992. */
  34993. materials: Material[];
  34994. /**
  34995. * The list of morph target managers added to the scene
  34996. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34997. */
  34998. morphTargetManagers: MorphTargetManager[];
  34999. /**
  35000. * The list of geometries used in the scene.
  35001. */
  35002. geometries: Geometry[];
  35003. /**
  35004. * All of the tranform nodes added to this scene
  35005. * In the context of a Scene, it is not supposed to be modified manually.
  35006. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35007. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35008. * @see http://doc.babylonjs.com/how_to/transformnode
  35009. */
  35010. transformNodes: TransformNode[];
  35011. /**
  35012. * ActionManagers available on the scene.
  35013. */
  35014. actionManagers: AbstractActionManager[];
  35015. /**
  35016. * Textures to keep.
  35017. */
  35018. textures: BaseTexture[];
  35019. /**
  35020. * Environment texture for the scene
  35021. */
  35022. environmentTexture: Nullable<BaseTexture>;
  35023. }
  35024. }
  35025. declare module BABYLON {
  35026. /**
  35027. * Interface used to define options for Sound class
  35028. */
  35029. export interface ISoundOptions {
  35030. /**
  35031. * Does the sound autoplay once loaded.
  35032. */
  35033. autoplay?: boolean;
  35034. /**
  35035. * Does the sound loop after it finishes playing once.
  35036. */
  35037. loop?: boolean;
  35038. /**
  35039. * Sound's volume
  35040. */
  35041. volume?: number;
  35042. /**
  35043. * Is it a spatial sound?
  35044. */
  35045. spatialSound?: boolean;
  35046. /**
  35047. * Maximum distance to hear that sound
  35048. */
  35049. maxDistance?: number;
  35050. /**
  35051. * Uses user defined attenuation function
  35052. */
  35053. useCustomAttenuation?: boolean;
  35054. /**
  35055. * Define the roll off factor of spatial sounds.
  35056. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35057. */
  35058. rolloffFactor?: number;
  35059. /**
  35060. * Define the reference distance the sound should be heard perfectly.
  35061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35062. */
  35063. refDistance?: number;
  35064. /**
  35065. * Define the distance attenuation model the sound will follow.
  35066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35067. */
  35068. distanceModel?: string;
  35069. /**
  35070. * Defines the playback speed (1 by default)
  35071. */
  35072. playbackRate?: number;
  35073. /**
  35074. * Defines if the sound is from a streaming source
  35075. */
  35076. streaming?: boolean;
  35077. /**
  35078. * Defines an optional length (in seconds) inside the sound file
  35079. */
  35080. length?: number;
  35081. /**
  35082. * Defines an optional offset (in seconds) inside the sound file
  35083. */
  35084. offset?: number;
  35085. /**
  35086. * If true, URLs will not be required to state the audio file codec to use.
  35087. */
  35088. skipCodecCheck?: boolean;
  35089. }
  35090. /**
  35091. * Defines a sound that can be played in the application.
  35092. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35094. */
  35095. export class Sound {
  35096. /**
  35097. * The name of the sound in the scene.
  35098. */
  35099. name: string;
  35100. /**
  35101. * Does the sound autoplay once loaded.
  35102. */
  35103. autoplay: boolean;
  35104. /**
  35105. * Does the sound loop after it finishes playing once.
  35106. */
  35107. loop: boolean;
  35108. /**
  35109. * Does the sound use a custom attenuation curve to simulate the falloff
  35110. * happening when the source gets further away from the camera.
  35111. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35112. */
  35113. useCustomAttenuation: boolean;
  35114. /**
  35115. * The sound track id this sound belongs to.
  35116. */
  35117. soundTrackId: number;
  35118. /**
  35119. * Is this sound currently played.
  35120. */
  35121. isPlaying: boolean;
  35122. /**
  35123. * Is this sound currently paused.
  35124. */
  35125. isPaused: boolean;
  35126. /**
  35127. * Does this sound enables spatial sound.
  35128. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35129. */
  35130. spatialSound: boolean;
  35131. /**
  35132. * Define the reference distance the sound should be heard perfectly.
  35133. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35134. */
  35135. refDistance: number;
  35136. /**
  35137. * Define the roll off factor of spatial sounds.
  35138. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35139. */
  35140. rolloffFactor: number;
  35141. /**
  35142. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35143. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35144. */
  35145. maxDistance: number;
  35146. /**
  35147. * Define the distance attenuation model the sound will follow.
  35148. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35149. */
  35150. distanceModel: string;
  35151. /**
  35152. * @hidden
  35153. * Back Compat
  35154. **/
  35155. onended: () => any;
  35156. /**
  35157. * Observable event when the current playing sound finishes.
  35158. */
  35159. onEndedObservable: Observable<Sound>;
  35160. private _panningModel;
  35161. private _playbackRate;
  35162. private _streaming;
  35163. private _startTime;
  35164. private _startOffset;
  35165. private _position;
  35166. /** @hidden */
  35167. _positionInEmitterSpace: boolean;
  35168. private _localDirection;
  35169. private _volume;
  35170. private _isReadyToPlay;
  35171. private _isDirectional;
  35172. private _readyToPlayCallback;
  35173. private _audioBuffer;
  35174. private _soundSource;
  35175. private _streamingSource;
  35176. private _soundPanner;
  35177. private _soundGain;
  35178. private _inputAudioNode;
  35179. private _outputAudioNode;
  35180. private _coneInnerAngle;
  35181. private _coneOuterAngle;
  35182. private _coneOuterGain;
  35183. private _scene;
  35184. private _connectedTransformNode;
  35185. private _customAttenuationFunction;
  35186. private _registerFunc;
  35187. private _isOutputConnected;
  35188. private _htmlAudioElement;
  35189. private _urlType;
  35190. private _length?;
  35191. private _offset?;
  35192. /** @hidden */
  35193. static _SceneComponentInitialization: (scene: Scene) => void;
  35194. /**
  35195. * Create a sound and attach it to a scene
  35196. * @param name Name of your sound
  35197. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35198. * @param scene defines the scene the sound belongs to
  35199. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35200. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35201. */
  35202. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35203. /**
  35204. * Release the sound and its associated resources
  35205. */
  35206. dispose(): void;
  35207. /**
  35208. * Gets if the sounds is ready to be played or not.
  35209. * @returns true if ready, otherwise false
  35210. */
  35211. isReady(): boolean;
  35212. private _soundLoaded;
  35213. /**
  35214. * Sets the data of the sound from an audiobuffer
  35215. * @param audioBuffer The audioBuffer containing the data
  35216. */
  35217. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35218. /**
  35219. * Updates the current sounds options such as maxdistance, loop...
  35220. * @param options A JSON object containing values named as the object properties
  35221. */
  35222. updateOptions(options: ISoundOptions): void;
  35223. private _createSpatialParameters;
  35224. private _updateSpatialParameters;
  35225. /**
  35226. * Switch the panning model to HRTF:
  35227. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35229. */
  35230. switchPanningModelToHRTF(): void;
  35231. /**
  35232. * Switch the panning model to Equal Power:
  35233. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35234. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35235. */
  35236. switchPanningModelToEqualPower(): void;
  35237. private _switchPanningModel;
  35238. /**
  35239. * Connect this sound to a sound track audio node like gain...
  35240. * @param soundTrackAudioNode the sound track audio node to connect to
  35241. */
  35242. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35243. /**
  35244. * Transform this sound into a directional source
  35245. * @param coneInnerAngle Size of the inner cone in degree
  35246. * @param coneOuterAngle Size of the outer cone in degree
  35247. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35248. */
  35249. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35250. /**
  35251. * Gets or sets the inner angle for the directional cone.
  35252. */
  35253. /**
  35254. * Gets or sets the inner angle for the directional cone.
  35255. */
  35256. directionalConeInnerAngle: number;
  35257. /**
  35258. * Gets or sets the outer angle for the directional cone.
  35259. */
  35260. /**
  35261. * Gets or sets the outer angle for the directional cone.
  35262. */
  35263. directionalConeOuterAngle: number;
  35264. /**
  35265. * Sets the position of the emitter if spatial sound is enabled
  35266. * @param newPosition Defines the new posisiton
  35267. */
  35268. setPosition(newPosition: Vector3): void;
  35269. /**
  35270. * Sets the local direction of the emitter if spatial sound is enabled
  35271. * @param newLocalDirection Defines the new local direction
  35272. */
  35273. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35274. private _updateDirection;
  35275. /** @hidden */
  35276. updateDistanceFromListener(): void;
  35277. /**
  35278. * Sets a new custom attenuation function for the sound.
  35279. * @param callback Defines the function used for the attenuation
  35280. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35281. */
  35282. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35283. /**
  35284. * Play the sound
  35285. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35286. * @param offset (optional) Start the sound at a specific time in seconds
  35287. * @param length (optional) Sound duration (in seconds)
  35288. */
  35289. play(time?: number, offset?: number, length?: number): void;
  35290. private _onended;
  35291. /**
  35292. * Stop the sound
  35293. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35294. */
  35295. stop(time?: number): void;
  35296. /**
  35297. * Put the sound in pause
  35298. */
  35299. pause(): void;
  35300. /**
  35301. * Sets a dedicated volume for this sounds
  35302. * @param newVolume Define the new volume of the sound
  35303. * @param time Define time for gradual change to new volume
  35304. */
  35305. setVolume(newVolume: number, time?: number): void;
  35306. /**
  35307. * Set the sound play back rate
  35308. * @param newPlaybackRate Define the playback rate the sound should be played at
  35309. */
  35310. setPlaybackRate(newPlaybackRate: number): void;
  35311. /**
  35312. * Gets the volume of the sound.
  35313. * @returns the volume of the sound
  35314. */
  35315. getVolume(): number;
  35316. /**
  35317. * Attach the sound to a dedicated mesh
  35318. * @param transformNode The transform node to connect the sound with
  35319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35320. */
  35321. attachToMesh(transformNode: TransformNode): void;
  35322. /**
  35323. * Detach the sound from the previously attached mesh
  35324. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35325. */
  35326. detachFromMesh(): void;
  35327. private _onRegisterAfterWorldMatrixUpdate;
  35328. /**
  35329. * Clone the current sound in the scene.
  35330. * @returns the new sound clone
  35331. */
  35332. clone(): Nullable<Sound>;
  35333. /**
  35334. * Gets the current underlying audio buffer containing the data
  35335. * @returns the audio buffer
  35336. */
  35337. getAudioBuffer(): Nullable<AudioBuffer>;
  35338. /**
  35339. * Serializes the Sound in a JSON representation
  35340. * @returns the JSON representation of the sound
  35341. */
  35342. serialize(): any;
  35343. /**
  35344. * Parse a JSON representation of a sound to innstantiate in a given scene
  35345. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35346. * @param scene Define the scene the new parsed sound should be created in
  35347. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35348. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35349. * @returns the newly parsed sound
  35350. */
  35351. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35352. }
  35353. }
  35354. declare module BABYLON {
  35355. /**
  35356. * This defines an action helpful to play a defined sound on a triggered action.
  35357. */
  35358. export class PlaySoundAction extends Action {
  35359. private _sound;
  35360. /**
  35361. * Instantiate the action
  35362. * @param triggerOptions defines the trigger options
  35363. * @param sound defines the sound to play
  35364. * @param condition defines the trigger related conditions
  35365. */
  35366. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35367. /** @hidden */
  35368. _prepare(): void;
  35369. /**
  35370. * Execute the action and play the sound.
  35371. */
  35372. execute(): void;
  35373. /**
  35374. * Serializes the actions and its related information.
  35375. * @param parent defines the object to serialize in
  35376. * @returns the serialized object
  35377. */
  35378. serialize(parent: any): any;
  35379. }
  35380. /**
  35381. * This defines an action helpful to stop a defined sound on a triggered action.
  35382. */
  35383. export class StopSoundAction extends Action {
  35384. private _sound;
  35385. /**
  35386. * Instantiate the action
  35387. * @param triggerOptions defines the trigger options
  35388. * @param sound defines the sound to stop
  35389. * @param condition defines the trigger related conditions
  35390. */
  35391. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35392. /** @hidden */
  35393. _prepare(): void;
  35394. /**
  35395. * Execute the action and stop the sound.
  35396. */
  35397. execute(): void;
  35398. /**
  35399. * Serializes the actions and its related information.
  35400. * @param parent defines the object to serialize in
  35401. * @returns the serialized object
  35402. */
  35403. serialize(parent: any): any;
  35404. }
  35405. }
  35406. declare module BABYLON {
  35407. /**
  35408. * This defines an action responsible to change the value of a property
  35409. * by interpolating between its current value and the newly set one once triggered.
  35410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35411. */
  35412. export class InterpolateValueAction extends Action {
  35413. /**
  35414. * Defines the path of the property where the value should be interpolated
  35415. */
  35416. propertyPath: string;
  35417. /**
  35418. * Defines the target value at the end of the interpolation.
  35419. */
  35420. value: any;
  35421. /**
  35422. * Defines the time it will take for the property to interpolate to the value.
  35423. */
  35424. duration: number;
  35425. /**
  35426. * Defines if the other scene animations should be stopped when the action has been triggered
  35427. */
  35428. stopOtherAnimations?: boolean;
  35429. /**
  35430. * Defines a callback raised once the interpolation animation has been done.
  35431. */
  35432. onInterpolationDone?: () => void;
  35433. /**
  35434. * Observable triggered once the interpolation animation has been done.
  35435. */
  35436. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35437. private _target;
  35438. private _effectiveTarget;
  35439. private _property;
  35440. /**
  35441. * Instantiate the action
  35442. * @param triggerOptions defines the trigger options
  35443. * @param target defines the object containing the value to interpolate
  35444. * @param propertyPath defines the path to the property in the target object
  35445. * @param value defines the target value at the end of the interpolation
  35446. * @param duration deines the time it will take for the property to interpolate to the value.
  35447. * @param condition defines the trigger related conditions
  35448. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35449. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35450. */
  35451. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35452. /** @hidden */
  35453. _prepare(): void;
  35454. /**
  35455. * Execute the action starts the value interpolation.
  35456. */
  35457. execute(): void;
  35458. /**
  35459. * Serializes the actions and its related information.
  35460. * @param parent defines the object to serialize in
  35461. * @returns the serialized object
  35462. */
  35463. serialize(parent: any): any;
  35464. }
  35465. }
  35466. declare module BABYLON {
  35467. /**
  35468. * Options allowed during the creation of a sound track.
  35469. */
  35470. export interface ISoundTrackOptions {
  35471. /**
  35472. * The volume the sound track should take during creation
  35473. */
  35474. volume?: number;
  35475. /**
  35476. * Define if the sound track is the main sound track of the scene
  35477. */
  35478. mainTrack?: boolean;
  35479. }
  35480. /**
  35481. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35482. * It will be also used in a future release to apply effects on a specific track.
  35483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35484. */
  35485. export class SoundTrack {
  35486. /**
  35487. * The unique identifier of the sound track in the scene.
  35488. */
  35489. id: number;
  35490. /**
  35491. * The list of sounds included in the sound track.
  35492. */
  35493. soundCollection: Array<Sound>;
  35494. private _outputAudioNode;
  35495. private _scene;
  35496. private _isMainTrack;
  35497. private _connectedAnalyser;
  35498. private _options;
  35499. private _isInitialized;
  35500. /**
  35501. * Creates a new sound track.
  35502. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35503. * @param scene Define the scene the sound track belongs to
  35504. * @param options
  35505. */
  35506. constructor(scene: Scene, options?: ISoundTrackOptions);
  35507. private _initializeSoundTrackAudioGraph;
  35508. /**
  35509. * Release the sound track and its associated resources
  35510. */
  35511. dispose(): void;
  35512. /**
  35513. * Adds a sound to this sound track
  35514. * @param sound define the cound to add
  35515. * @ignoreNaming
  35516. */
  35517. AddSound(sound: Sound): void;
  35518. /**
  35519. * Removes a sound to this sound track
  35520. * @param sound define the cound to remove
  35521. * @ignoreNaming
  35522. */
  35523. RemoveSound(sound: Sound): void;
  35524. /**
  35525. * Set a global volume for the full sound track.
  35526. * @param newVolume Define the new volume of the sound track
  35527. */
  35528. setVolume(newVolume: number): void;
  35529. /**
  35530. * Switch the panning model to HRTF:
  35531. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35533. */
  35534. switchPanningModelToHRTF(): void;
  35535. /**
  35536. * Switch the panning model to Equal Power:
  35537. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35539. */
  35540. switchPanningModelToEqualPower(): void;
  35541. /**
  35542. * Connect the sound track to an audio analyser allowing some amazing
  35543. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35545. * @param analyser The analyser to connect to the engine
  35546. */
  35547. connectToAnalyser(analyser: Analyser): void;
  35548. }
  35549. }
  35550. declare module BABYLON {
  35551. interface AbstractScene {
  35552. /**
  35553. * The list of sounds used in the scene.
  35554. */
  35555. sounds: Nullable<Array<Sound>>;
  35556. }
  35557. interface Scene {
  35558. /**
  35559. * @hidden
  35560. * Backing field
  35561. */
  35562. _mainSoundTrack: SoundTrack;
  35563. /**
  35564. * The main sound track played by the scene.
  35565. * It cotains your primary collection of sounds.
  35566. */
  35567. mainSoundTrack: SoundTrack;
  35568. /**
  35569. * The list of sound tracks added to the scene
  35570. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35571. */
  35572. soundTracks: Nullable<Array<SoundTrack>>;
  35573. /**
  35574. * Gets a sound using a given name
  35575. * @param name defines the name to search for
  35576. * @return the found sound or null if not found at all.
  35577. */
  35578. getSoundByName(name: string): Nullable<Sound>;
  35579. /**
  35580. * Gets or sets if audio support is enabled
  35581. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35582. */
  35583. audioEnabled: boolean;
  35584. /**
  35585. * Gets or sets if audio will be output to headphones
  35586. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35587. */
  35588. headphone: boolean;
  35589. /**
  35590. * Gets or sets custom audio listener position provider
  35591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35592. */
  35593. audioListenerPositionProvider: Nullable<() => Vector3>;
  35594. }
  35595. /**
  35596. * Defines the sound scene component responsible to manage any sounds
  35597. * in a given scene.
  35598. */
  35599. export class AudioSceneComponent implements ISceneSerializableComponent {
  35600. /**
  35601. * The component name helpfull to identify the component in the list of scene components.
  35602. */
  35603. readonly name: string;
  35604. /**
  35605. * The scene the component belongs to.
  35606. */
  35607. scene: Scene;
  35608. private _audioEnabled;
  35609. /**
  35610. * Gets whether audio is enabled or not.
  35611. * Please use related enable/disable method to switch state.
  35612. */
  35613. readonly audioEnabled: boolean;
  35614. private _headphone;
  35615. /**
  35616. * Gets whether audio is outputing to headphone or not.
  35617. * Please use the according Switch methods to change output.
  35618. */
  35619. readonly headphone: boolean;
  35620. private _audioListenerPositionProvider;
  35621. /**
  35622. * Gets the current audio listener position provider
  35623. */
  35624. /**
  35625. * Sets a custom listener position for all sounds in the scene
  35626. * By default, this is the position of the first active camera
  35627. */
  35628. audioListenerPositionProvider: Nullable<() => Vector3>;
  35629. /**
  35630. * Creates a new instance of the component for the given scene
  35631. * @param scene Defines the scene to register the component in
  35632. */
  35633. constructor(scene: Scene);
  35634. /**
  35635. * Registers the component in a given scene
  35636. */
  35637. register(): void;
  35638. /**
  35639. * Rebuilds the elements related to this component in case of
  35640. * context lost for instance.
  35641. */
  35642. rebuild(): void;
  35643. /**
  35644. * Serializes the component data to the specified json object
  35645. * @param serializationObject The object to serialize to
  35646. */
  35647. serialize(serializationObject: any): void;
  35648. /**
  35649. * Adds all the elements from the container to the scene
  35650. * @param container the container holding the elements
  35651. */
  35652. addFromContainer(container: AbstractScene): void;
  35653. /**
  35654. * Removes all the elements in the container from the scene
  35655. * @param container contains the elements to remove
  35656. * @param dispose if the removed element should be disposed (default: false)
  35657. */
  35658. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35659. /**
  35660. * Disposes the component and the associated ressources.
  35661. */
  35662. dispose(): void;
  35663. /**
  35664. * Disables audio in the associated scene.
  35665. */
  35666. disableAudio(): void;
  35667. /**
  35668. * Enables audio in the associated scene.
  35669. */
  35670. enableAudio(): void;
  35671. /**
  35672. * Switch audio to headphone output.
  35673. */
  35674. switchAudioModeForHeadphones(): void;
  35675. /**
  35676. * Switch audio to normal speakers.
  35677. */
  35678. switchAudioModeForNormalSpeakers(): void;
  35679. private _afterRender;
  35680. }
  35681. }
  35682. declare module BABYLON {
  35683. /**
  35684. * Wraps one or more Sound objects and selects one with random weight for playback.
  35685. */
  35686. export class WeightedSound {
  35687. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35688. loop: boolean;
  35689. private _coneInnerAngle;
  35690. private _coneOuterAngle;
  35691. private _volume;
  35692. /** A Sound is currently playing. */
  35693. isPlaying: boolean;
  35694. /** A Sound is currently paused. */
  35695. isPaused: boolean;
  35696. private _sounds;
  35697. private _weights;
  35698. private _currentIndex?;
  35699. /**
  35700. * Creates a new WeightedSound from the list of sounds given.
  35701. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35702. * @param sounds Array of Sounds that will be selected from.
  35703. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35704. */
  35705. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35706. /**
  35707. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35708. */
  35709. /**
  35710. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35711. */
  35712. directionalConeInnerAngle: number;
  35713. /**
  35714. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35715. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35716. */
  35717. /**
  35718. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35719. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35720. */
  35721. directionalConeOuterAngle: number;
  35722. /**
  35723. * Playback volume.
  35724. */
  35725. /**
  35726. * Playback volume.
  35727. */
  35728. volume: number;
  35729. private _onended;
  35730. /**
  35731. * Suspend playback
  35732. */
  35733. pause(): void;
  35734. /**
  35735. * Stop playback
  35736. */
  35737. stop(): void;
  35738. /**
  35739. * Start playback.
  35740. * @param startOffset Position the clip head at a specific time in seconds.
  35741. */
  35742. play(startOffset?: number): void;
  35743. }
  35744. }
  35745. declare module BABYLON {
  35746. /**
  35747. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35748. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35749. */
  35750. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35751. /**
  35752. * Gets the name of the behavior.
  35753. */
  35754. readonly name: string;
  35755. /**
  35756. * The easing function used by animations
  35757. */
  35758. static EasingFunction: BackEase;
  35759. /**
  35760. * The easing mode used by animations
  35761. */
  35762. static EasingMode: number;
  35763. /**
  35764. * The duration of the animation, in milliseconds
  35765. */
  35766. transitionDuration: number;
  35767. /**
  35768. * Length of the distance animated by the transition when lower radius is reached
  35769. */
  35770. lowerRadiusTransitionRange: number;
  35771. /**
  35772. * Length of the distance animated by the transition when upper radius is reached
  35773. */
  35774. upperRadiusTransitionRange: number;
  35775. private _autoTransitionRange;
  35776. /**
  35777. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35778. */
  35779. /**
  35780. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35781. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35782. */
  35783. autoTransitionRange: boolean;
  35784. private _attachedCamera;
  35785. private _onAfterCheckInputsObserver;
  35786. private _onMeshTargetChangedObserver;
  35787. /**
  35788. * Initializes the behavior.
  35789. */
  35790. init(): void;
  35791. /**
  35792. * Attaches the behavior to its arc rotate camera.
  35793. * @param camera Defines the camera to attach the behavior to
  35794. */
  35795. attach(camera: ArcRotateCamera): void;
  35796. /**
  35797. * Detaches the behavior from its current arc rotate camera.
  35798. */
  35799. detach(): void;
  35800. private _radiusIsAnimating;
  35801. private _radiusBounceTransition;
  35802. private _animatables;
  35803. private _cachedWheelPrecision;
  35804. /**
  35805. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35806. * @param radiusLimit The limit to check against.
  35807. * @return Bool to indicate if at limit.
  35808. */
  35809. private _isRadiusAtLimit;
  35810. /**
  35811. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35812. * @param radiusDelta The delta by which to animate to. Can be negative.
  35813. */
  35814. private _applyBoundRadiusAnimation;
  35815. /**
  35816. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35817. */
  35818. protected _clearAnimationLocks(): void;
  35819. /**
  35820. * Stops and removes all animations that have been applied to the camera
  35821. */
  35822. stopAllAnimations(): void;
  35823. }
  35824. }
  35825. declare module BABYLON {
  35826. /**
  35827. * 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.
  35828. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35829. */
  35830. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35831. /**
  35832. * Gets the name of the behavior.
  35833. */
  35834. readonly name: string;
  35835. private _mode;
  35836. private _radiusScale;
  35837. private _positionScale;
  35838. private _defaultElevation;
  35839. private _elevationReturnTime;
  35840. private _elevationReturnWaitTime;
  35841. private _zoomStopsAnimation;
  35842. private _framingTime;
  35843. /**
  35844. * The easing function used by animations
  35845. */
  35846. static EasingFunction: ExponentialEase;
  35847. /**
  35848. * The easing mode used by animations
  35849. */
  35850. static EasingMode: number;
  35851. /**
  35852. * Sets the current mode used by the behavior
  35853. */
  35854. /**
  35855. * Gets current mode used by the behavior.
  35856. */
  35857. mode: number;
  35858. /**
  35859. * Sets the scale applied to the radius (1 by default)
  35860. */
  35861. /**
  35862. * Gets the scale applied to the radius
  35863. */
  35864. radiusScale: number;
  35865. /**
  35866. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35867. */
  35868. /**
  35869. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35870. */
  35871. positionScale: number;
  35872. /**
  35873. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35874. * behaviour is triggered, in radians.
  35875. */
  35876. /**
  35877. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35878. * behaviour is triggered, in radians.
  35879. */
  35880. defaultElevation: number;
  35881. /**
  35882. * Sets the time (in milliseconds) taken to return to the default beta position.
  35883. * Negative value indicates camera should not return to default.
  35884. */
  35885. /**
  35886. * Gets the time (in milliseconds) taken to return to the default beta position.
  35887. * Negative value indicates camera should not return to default.
  35888. */
  35889. elevationReturnTime: number;
  35890. /**
  35891. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35892. */
  35893. /**
  35894. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35895. */
  35896. elevationReturnWaitTime: number;
  35897. /**
  35898. * Sets the flag that indicates if user zooming should stop animation.
  35899. */
  35900. /**
  35901. * Gets the flag that indicates if user zooming should stop animation.
  35902. */
  35903. zoomStopsAnimation: boolean;
  35904. /**
  35905. * Sets the transition time when framing the mesh, in milliseconds
  35906. */
  35907. /**
  35908. * Gets the transition time when framing the mesh, in milliseconds
  35909. */
  35910. framingTime: number;
  35911. /**
  35912. * Define if the behavior should automatically change the configured
  35913. * camera limits and sensibilities.
  35914. */
  35915. autoCorrectCameraLimitsAndSensibility: boolean;
  35916. private _onPrePointerObservableObserver;
  35917. private _onAfterCheckInputsObserver;
  35918. private _onMeshTargetChangedObserver;
  35919. private _attachedCamera;
  35920. private _isPointerDown;
  35921. private _lastInteractionTime;
  35922. /**
  35923. * Initializes the behavior.
  35924. */
  35925. init(): void;
  35926. /**
  35927. * Attaches the behavior to its arc rotate camera.
  35928. * @param camera Defines the camera to attach the behavior to
  35929. */
  35930. attach(camera: ArcRotateCamera): void;
  35931. /**
  35932. * Detaches the behavior from its current arc rotate camera.
  35933. */
  35934. detach(): void;
  35935. private _animatables;
  35936. private _betaIsAnimating;
  35937. private _betaTransition;
  35938. private _radiusTransition;
  35939. private _vectorTransition;
  35940. /**
  35941. * Targets the given mesh and updates zoom level accordingly.
  35942. * @param mesh The mesh to target.
  35943. * @param radius Optional. If a cached radius position already exists, overrides default.
  35944. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35945. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35946. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35947. */
  35948. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35949. /**
  35950. * Targets the given mesh with its children and updates zoom level accordingly.
  35951. * @param mesh The mesh to target.
  35952. * @param radius Optional. If a cached radius position already exists, overrides default.
  35953. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35954. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35955. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35956. */
  35957. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35958. /**
  35959. * Targets the given meshes with their children and updates zoom level accordingly.
  35960. * @param meshes The mesh to target.
  35961. * @param radius Optional. If a cached radius position already exists, overrides default.
  35962. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35963. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35964. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35965. */
  35966. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35967. /**
  35968. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35969. * @param minimumWorld Determines the smaller position of the bounding box extend
  35970. * @param maximumWorld Determines the bigger position of the bounding box extend
  35971. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35972. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35973. */
  35974. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35975. /**
  35976. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35977. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35978. * frustum width.
  35979. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35980. * to fully enclose the mesh in the viewing frustum.
  35981. */
  35982. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35983. /**
  35984. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35985. * is automatically returned to its default position (expected to be above ground plane).
  35986. */
  35987. private _maintainCameraAboveGround;
  35988. /**
  35989. * Returns the frustum slope based on the canvas ratio and camera FOV
  35990. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35991. */
  35992. private _getFrustumSlope;
  35993. /**
  35994. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35995. */
  35996. private _clearAnimationLocks;
  35997. /**
  35998. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35999. */
  36000. private _applyUserInteraction;
  36001. /**
  36002. * Stops and removes all animations that have been applied to the camera
  36003. */
  36004. stopAllAnimations(): void;
  36005. /**
  36006. * Gets a value indicating if the user is moving the camera
  36007. */
  36008. readonly isUserIsMoving: boolean;
  36009. /**
  36010. * The camera can move all the way towards the mesh.
  36011. */
  36012. static IgnoreBoundsSizeMode: number;
  36013. /**
  36014. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36015. */
  36016. static FitFrustumSidesMode: number;
  36017. }
  36018. }
  36019. declare module BABYLON {
  36020. /**
  36021. * Base class for Camera Pointer Inputs.
  36022. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36023. * for example usage.
  36024. */
  36025. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36026. /**
  36027. * Defines the camera the input is attached to.
  36028. */
  36029. abstract camera: Camera;
  36030. /**
  36031. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36032. */
  36033. protected _altKey: boolean;
  36034. protected _ctrlKey: boolean;
  36035. protected _metaKey: boolean;
  36036. protected _shiftKey: boolean;
  36037. /**
  36038. * Which mouse buttons were pressed at time of last mouse event.
  36039. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36040. */
  36041. protected _buttonsPressed: number;
  36042. /**
  36043. * Defines the buttons associated with the input to handle camera move.
  36044. */
  36045. buttons: number[];
  36046. /**
  36047. * Attach the input controls to a specific dom element to get the input from.
  36048. * @param element Defines the element the controls should be listened from
  36049. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36050. */
  36051. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36052. /**
  36053. * Detach the current controls from the specified dom element.
  36054. * @param element Defines the element to stop listening the inputs from
  36055. */
  36056. detachControl(element: Nullable<HTMLElement>): void;
  36057. /**
  36058. * Gets the class name of the current input.
  36059. * @returns the class name
  36060. */
  36061. getClassName(): string;
  36062. /**
  36063. * Get the friendly name associated with the input class.
  36064. * @returns the input friendly name
  36065. */
  36066. getSimpleName(): string;
  36067. /**
  36068. * Called on pointer POINTERDOUBLETAP event.
  36069. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36070. */
  36071. protected onDoubleTap(type: string): void;
  36072. /**
  36073. * Called on pointer POINTERMOVE event if only a single touch is active.
  36074. * Override this method to provide functionality.
  36075. */
  36076. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36077. /**
  36078. * Called on pointer POINTERMOVE event if multiple touches are active.
  36079. * Override this method to provide functionality.
  36080. */
  36081. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36082. /**
  36083. * Called on JS contextmenu event.
  36084. * Override this method to provide functionality.
  36085. */
  36086. protected onContextMenu(evt: PointerEvent): void;
  36087. /**
  36088. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36089. * press.
  36090. * Override this method to provide functionality.
  36091. */
  36092. protected onButtonDown(evt: PointerEvent): void;
  36093. /**
  36094. * Called each time a new POINTERUP event occurs. Ie, for each button
  36095. * release.
  36096. * Override this method to provide functionality.
  36097. */
  36098. protected onButtonUp(evt: PointerEvent): void;
  36099. /**
  36100. * Called when window becomes inactive.
  36101. * Override this method to provide functionality.
  36102. */
  36103. protected onLostFocus(): void;
  36104. private _pointerInput;
  36105. private _observer;
  36106. private _onLostFocus;
  36107. private pointA;
  36108. private pointB;
  36109. }
  36110. }
  36111. declare module BABYLON {
  36112. /**
  36113. * Manage the pointers inputs to control an arc rotate camera.
  36114. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36115. */
  36116. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36117. /**
  36118. * Defines the camera the input is attached to.
  36119. */
  36120. camera: ArcRotateCamera;
  36121. /**
  36122. * Gets the class name of the current input.
  36123. * @returns the class name
  36124. */
  36125. getClassName(): string;
  36126. /**
  36127. * Defines the buttons associated with the input to handle camera move.
  36128. */
  36129. buttons: number[];
  36130. /**
  36131. * Defines the pointer angular sensibility along the X axis or how fast is
  36132. * the camera rotating.
  36133. */
  36134. angularSensibilityX: number;
  36135. /**
  36136. * Defines the pointer angular sensibility along the Y axis or how fast is
  36137. * the camera rotating.
  36138. */
  36139. angularSensibilityY: number;
  36140. /**
  36141. * Defines the pointer pinch precision or how fast is the camera zooming.
  36142. */
  36143. pinchPrecision: number;
  36144. /**
  36145. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36146. * from 0.
  36147. * It defines the percentage of current camera.radius to use as delta when
  36148. * pinch zoom is used.
  36149. */
  36150. pinchDeltaPercentage: number;
  36151. /**
  36152. * Defines the pointer panning sensibility or how fast is the camera moving.
  36153. */
  36154. panningSensibility: number;
  36155. /**
  36156. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36157. */
  36158. multiTouchPanning: boolean;
  36159. /**
  36160. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36161. * zoom (pinch) through multitouch.
  36162. */
  36163. multiTouchPanAndZoom: boolean;
  36164. /**
  36165. * Revers pinch action direction.
  36166. */
  36167. pinchInwards: boolean;
  36168. private _isPanClick;
  36169. private _twoFingerActivityCount;
  36170. private _isPinching;
  36171. /**
  36172. * Called on pointer POINTERMOVE event if only a single touch is active.
  36173. */
  36174. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36175. /**
  36176. * Called on pointer POINTERDOUBLETAP event.
  36177. */
  36178. protected onDoubleTap(type: string): void;
  36179. /**
  36180. * Called on pointer POINTERMOVE event if multiple touches are active.
  36181. */
  36182. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36183. /**
  36184. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36185. * press.
  36186. */
  36187. protected onButtonDown(evt: PointerEvent): void;
  36188. /**
  36189. * Called each time a new POINTERUP event occurs. Ie, for each button
  36190. * release.
  36191. */
  36192. protected onButtonUp(evt: PointerEvent): void;
  36193. /**
  36194. * Called when window becomes inactive.
  36195. */
  36196. protected onLostFocus(): void;
  36197. }
  36198. }
  36199. declare module BABYLON {
  36200. /**
  36201. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36203. */
  36204. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36205. /**
  36206. * Defines the camera the input is attached to.
  36207. */
  36208. camera: ArcRotateCamera;
  36209. /**
  36210. * Defines the list of key codes associated with the up action (increase alpha)
  36211. */
  36212. keysUp: number[];
  36213. /**
  36214. * Defines the list of key codes associated with the down action (decrease alpha)
  36215. */
  36216. keysDown: number[];
  36217. /**
  36218. * Defines the list of key codes associated with the left action (increase beta)
  36219. */
  36220. keysLeft: number[];
  36221. /**
  36222. * Defines the list of key codes associated with the right action (decrease beta)
  36223. */
  36224. keysRight: number[];
  36225. /**
  36226. * Defines the list of key codes associated with the reset action.
  36227. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36228. */
  36229. keysReset: number[];
  36230. /**
  36231. * Defines the panning sensibility of the inputs.
  36232. * (How fast is the camera paning)
  36233. */
  36234. panningSensibility: number;
  36235. /**
  36236. * Defines the zooming sensibility of the inputs.
  36237. * (How fast is the camera zooming)
  36238. */
  36239. zoomingSensibility: number;
  36240. /**
  36241. * Defines wether maintaining the alt key down switch the movement mode from
  36242. * orientation to zoom.
  36243. */
  36244. useAltToZoom: boolean;
  36245. /**
  36246. * Rotation speed of the camera
  36247. */
  36248. angularSpeed: number;
  36249. private _keys;
  36250. private _ctrlPressed;
  36251. private _altPressed;
  36252. private _onCanvasBlurObserver;
  36253. private _onKeyboardObserver;
  36254. private _engine;
  36255. private _scene;
  36256. /**
  36257. * Attach the input controls to a specific dom element to get the input from.
  36258. * @param element Defines the element the controls should be listened from
  36259. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36260. */
  36261. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36262. /**
  36263. * Detach the current controls from the specified dom element.
  36264. * @param element Defines the element to stop listening the inputs from
  36265. */
  36266. detachControl(element: Nullable<HTMLElement>): void;
  36267. /**
  36268. * Update the current camera state depending on the inputs that have been used this frame.
  36269. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36270. */
  36271. checkInputs(): void;
  36272. /**
  36273. * Gets the class name of the current intput.
  36274. * @returns the class name
  36275. */
  36276. getClassName(): string;
  36277. /**
  36278. * Get the friendly name associated with the input class.
  36279. * @returns the input friendly name
  36280. */
  36281. getSimpleName(): string;
  36282. }
  36283. }
  36284. declare module BABYLON {
  36285. /**
  36286. * Manage the mouse wheel inputs to control an arc rotate camera.
  36287. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36288. */
  36289. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36290. /**
  36291. * Defines the camera the input is attached to.
  36292. */
  36293. camera: ArcRotateCamera;
  36294. /**
  36295. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36296. */
  36297. wheelPrecision: number;
  36298. /**
  36299. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36300. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36301. */
  36302. wheelDeltaPercentage: number;
  36303. private _wheel;
  36304. private _observer;
  36305. private computeDeltaFromMouseWheelLegacyEvent;
  36306. /**
  36307. * Attach the input controls to a specific dom element to get the input from.
  36308. * @param element Defines the element the controls should be listened from
  36309. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36310. */
  36311. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36312. /**
  36313. * Detach the current controls from the specified dom element.
  36314. * @param element Defines the element to stop listening the inputs from
  36315. */
  36316. detachControl(element: Nullable<HTMLElement>): void;
  36317. /**
  36318. * Gets the class name of the current intput.
  36319. * @returns the class name
  36320. */
  36321. getClassName(): string;
  36322. /**
  36323. * Get the friendly name associated with the input class.
  36324. * @returns the input friendly name
  36325. */
  36326. getSimpleName(): string;
  36327. }
  36328. }
  36329. declare module BABYLON {
  36330. /**
  36331. * Default Inputs manager for the ArcRotateCamera.
  36332. * It groups all the default supported inputs for ease of use.
  36333. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36334. */
  36335. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36336. /**
  36337. * Instantiates a new ArcRotateCameraInputsManager.
  36338. * @param camera Defines the camera the inputs belong to
  36339. */
  36340. constructor(camera: ArcRotateCamera);
  36341. /**
  36342. * Add mouse wheel input support to the input manager.
  36343. * @returns the current input manager
  36344. */
  36345. addMouseWheel(): ArcRotateCameraInputsManager;
  36346. /**
  36347. * Add pointers input support to the input manager.
  36348. * @returns the current input manager
  36349. */
  36350. addPointers(): ArcRotateCameraInputsManager;
  36351. /**
  36352. * Add keyboard input support to the input manager.
  36353. * @returns the current input manager
  36354. */
  36355. addKeyboard(): ArcRotateCameraInputsManager;
  36356. }
  36357. }
  36358. declare module BABYLON {
  36359. /**
  36360. * This represents an orbital type of camera.
  36361. *
  36362. * 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.
  36363. * 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.
  36364. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36365. */
  36366. export class ArcRotateCamera extends TargetCamera {
  36367. /**
  36368. * Defines the rotation angle of the camera along the longitudinal axis.
  36369. */
  36370. alpha: number;
  36371. /**
  36372. * Defines the rotation angle of the camera along the latitudinal axis.
  36373. */
  36374. beta: number;
  36375. /**
  36376. * Defines the radius of the camera from it s target point.
  36377. */
  36378. radius: number;
  36379. protected _target: Vector3;
  36380. protected _targetHost: Nullable<AbstractMesh>;
  36381. /**
  36382. * Defines the target point of the camera.
  36383. * The camera looks towards it form the radius distance.
  36384. */
  36385. target: Vector3;
  36386. /**
  36387. * Define the current local position of the camera in the scene
  36388. */
  36389. position: Vector3;
  36390. protected _upVector: Vector3;
  36391. protected _upToYMatrix: Matrix;
  36392. protected _YToUpMatrix: Matrix;
  36393. /**
  36394. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36395. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36396. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36397. */
  36398. upVector: Vector3;
  36399. /**
  36400. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36401. */
  36402. setMatUp(): void;
  36403. /**
  36404. * Current inertia value on the longitudinal axis.
  36405. * The bigger this number the longer it will take for the camera to stop.
  36406. */
  36407. inertialAlphaOffset: number;
  36408. /**
  36409. * Current inertia value on the latitudinal axis.
  36410. * The bigger this number the longer it will take for the camera to stop.
  36411. */
  36412. inertialBetaOffset: number;
  36413. /**
  36414. * Current inertia value on the radius axis.
  36415. * The bigger this number the longer it will take for the camera to stop.
  36416. */
  36417. inertialRadiusOffset: number;
  36418. /**
  36419. * Minimum allowed angle on the longitudinal axis.
  36420. * This can help limiting how the Camera is able to move in the scene.
  36421. */
  36422. lowerAlphaLimit: Nullable<number>;
  36423. /**
  36424. * Maximum allowed angle on the longitudinal axis.
  36425. * This can help limiting how the Camera is able to move in the scene.
  36426. */
  36427. upperAlphaLimit: Nullable<number>;
  36428. /**
  36429. * Minimum allowed angle on the latitudinal axis.
  36430. * This can help limiting how the Camera is able to move in the scene.
  36431. */
  36432. lowerBetaLimit: number;
  36433. /**
  36434. * Maximum allowed angle on the latitudinal axis.
  36435. * This can help limiting how the Camera is able to move in the scene.
  36436. */
  36437. upperBetaLimit: number;
  36438. /**
  36439. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36440. * This can help limiting how the Camera is able to move in the scene.
  36441. */
  36442. lowerRadiusLimit: Nullable<number>;
  36443. /**
  36444. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36445. * This can help limiting how the Camera is able to move in the scene.
  36446. */
  36447. upperRadiusLimit: Nullable<number>;
  36448. /**
  36449. * Defines the current inertia value used during panning of the camera along the X axis.
  36450. */
  36451. inertialPanningX: number;
  36452. /**
  36453. * Defines the current inertia value used during panning of the camera along the Y axis.
  36454. */
  36455. inertialPanningY: number;
  36456. /**
  36457. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36458. * Basically if your fingers moves away from more than this distance you will be considered
  36459. * in pinch mode.
  36460. */
  36461. pinchToPanMaxDistance: number;
  36462. /**
  36463. * Defines the maximum distance the camera can pan.
  36464. * This could help keeping the cammera always in your scene.
  36465. */
  36466. panningDistanceLimit: Nullable<number>;
  36467. /**
  36468. * Defines the target of the camera before paning.
  36469. */
  36470. panningOriginTarget: Vector3;
  36471. /**
  36472. * Defines the value of the inertia used during panning.
  36473. * 0 would mean stop inertia and one would mean no decelleration at all.
  36474. */
  36475. panningInertia: number;
  36476. /**
  36477. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36478. */
  36479. angularSensibilityX: number;
  36480. /**
  36481. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36482. */
  36483. angularSensibilityY: number;
  36484. /**
  36485. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36486. */
  36487. pinchPrecision: number;
  36488. /**
  36489. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36490. * It will be used instead of pinchDeltaPrecision if different from 0.
  36491. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36492. */
  36493. pinchDeltaPercentage: number;
  36494. /**
  36495. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36496. */
  36497. panningSensibility: number;
  36498. /**
  36499. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36500. */
  36501. keysUp: number[];
  36502. /**
  36503. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36504. */
  36505. keysDown: number[];
  36506. /**
  36507. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36508. */
  36509. keysLeft: number[];
  36510. /**
  36511. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36512. */
  36513. keysRight: number[];
  36514. /**
  36515. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36516. */
  36517. wheelPrecision: number;
  36518. /**
  36519. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36520. * It will be used instead of pinchDeltaPrecision if different from 0.
  36521. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36522. */
  36523. wheelDeltaPercentage: number;
  36524. /**
  36525. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36526. */
  36527. zoomOnFactor: number;
  36528. /**
  36529. * Defines a screen offset for the camera position.
  36530. */
  36531. targetScreenOffset: Vector2;
  36532. /**
  36533. * Allows the camera to be completely reversed.
  36534. * If false the camera can not arrive upside down.
  36535. */
  36536. allowUpsideDown: boolean;
  36537. /**
  36538. * Define if double tap/click is used to restore the previously saved state of the camera.
  36539. */
  36540. useInputToRestoreState: boolean;
  36541. /** @hidden */
  36542. _viewMatrix: Matrix;
  36543. /** @hidden */
  36544. _useCtrlForPanning: boolean;
  36545. /** @hidden */
  36546. _panningMouseButton: number;
  36547. /**
  36548. * Defines the input associated to the camera.
  36549. */
  36550. inputs: ArcRotateCameraInputsManager;
  36551. /** @hidden */
  36552. _reset: () => void;
  36553. /**
  36554. * Defines the allowed panning axis.
  36555. */
  36556. panningAxis: Vector3;
  36557. protected _localDirection: Vector3;
  36558. protected _transformedDirection: Vector3;
  36559. private _bouncingBehavior;
  36560. /**
  36561. * Gets the bouncing behavior of the camera if it has been enabled.
  36562. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36563. */
  36564. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36565. /**
  36566. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36567. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36568. */
  36569. useBouncingBehavior: boolean;
  36570. private _framingBehavior;
  36571. /**
  36572. * Gets the framing behavior of the camera if it has been enabled.
  36573. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36574. */
  36575. readonly framingBehavior: Nullable<FramingBehavior>;
  36576. /**
  36577. * Defines if the framing behavior of the camera is enabled on the camera.
  36578. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36579. */
  36580. useFramingBehavior: boolean;
  36581. private _autoRotationBehavior;
  36582. /**
  36583. * Gets the auto rotation behavior of the camera if it has been enabled.
  36584. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36585. */
  36586. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36587. /**
  36588. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36589. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36590. */
  36591. useAutoRotationBehavior: boolean;
  36592. /**
  36593. * Observable triggered when the mesh target has been changed on the camera.
  36594. */
  36595. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36596. /**
  36597. * Event raised when the camera is colliding with a mesh.
  36598. */
  36599. onCollide: (collidedMesh: AbstractMesh) => void;
  36600. /**
  36601. * Defines whether the camera should check collision with the objects oh the scene.
  36602. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36603. */
  36604. checkCollisions: boolean;
  36605. /**
  36606. * Defines the collision radius of the camera.
  36607. * This simulates a sphere around the camera.
  36608. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36609. */
  36610. collisionRadius: Vector3;
  36611. protected _collider: Collider;
  36612. protected _previousPosition: Vector3;
  36613. protected _collisionVelocity: Vector3;
  36614. protected _newPosition: Vector3;
  36615. protected _previousAlpha: number;
  36616. protected _previousBeta: number;
  36617. protected _previousRadius: number;
  36618. protected _collisionTriggered: boolean;
  36619. protected _targetBoundingCenter: Nullable<Vector3>;
  36620. private _computationVector;
  36621. /**
  36622. * Instantiates a new ArcRotateCamera in a given scene
  36623. * @param name Defines the name of the camera
  36624. * @param alpha Defines the camera rotation along the logitudinal axis
  36625. * @param beta Defines the camera rotation along the latitudinal axis
  36626. * @param radius Defines the camera distance from its target
  36627. * @param target Defines the camera target
  36628. * @param scene Defines the scene the camera belongs to
  36629. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36630. */
  36631. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36632. /** @hidden */
  36633. _initCache(): void;
  36634. /** @hidden */
  36635. _updateCache(ignoreParentClass?: boolean): void;
  36636. protected _getTargetPosition(): Vector3;
  36637. private _storedAlpha;
  36638. private _storedBeta;
  36639. private _storedRadius;
  36640. private _storedTarget;
  36641. private _storedTargetScreenOffset;
  36642. /**
  36643. * Stores the current state of the camera (alpha, beta, radius and target)
  36644. * @returns the camera itself
  36645. */
  36646. storeState(): Camera;
  36647. /**
  36648. * @hidden
  36649. * Restored camera state. You must call storeState() first
  36650. */
  36651. _restoreStateValues(): boolean;
  36652. /** @hidden */
  36653. _isSynchronizedViewMatrix(): boolean;
  36654. /**
  36655. * Attached controls to the current camera.
  36656. * @param element Defines the element the controls should be listened from
  36657. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36658. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36659. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36660. */
  36661. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36662. /**
  36663. * Detach the current controls from the camera.
  36664. * The camera will stop reacting to inputs.
  36665. * @param element Defines the element to stop listening the inputs from
  36666. */
  36667. detachControl(element: HTMLElement): void;
  36668. /** @hidden */
  36669. _checkInputs(): void;
  36670. protected _checkLimits(): void;
  36671. /**
  36672. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36673. */
  36674. rebuildAnglesAndRadius(): void;
  36675. /**
  36676. * Use a position to define the current camera related information like alpha, beta and radius
  36677. * @param position Defines the position to set the camera at
  36678. */
  36679. setPosition(position: Vector3): void;
  36680. /**
  36681. * Defines the target the camera should look at.
  36682. * This will automatically adapt alpha beta and radius to fit within the new target.
  36683. * @param target Defines the new target as a Vector or a mesh
  36684. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36685. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36686. */
  36687. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36688. /** @hidden */
  36689. _getViewMatrix(): Matrix;
  36690. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36691. /**
  36692. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36693. * @param meshes Defines the mesh to zoom on
  36694. * @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)
  36695. */
  36696. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36697. /**
  36698. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36699. * The target will be changed but the radius
  36700. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36701. * @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)
  36702. */
  36703. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36704. min: Vector3;
  36705. max: Vector3;
  36706. distance: number;
  36707. }, doNotUpdateMaxZ?: boolean): void;
  36708. /**
  36709. * @override
  36710. * Override Camera.createRigCamera
  36711. */
  36712. createRigCamera(name: string, cameraIndex: number): Camera;
  36713. /**
  36714. * @hidden
  36715. * @override
  36716. * Override Camera._updateRigCameras
  36717. */
  36718. _updateRigCameras(): void;
  36719. /**
  36720. * Destroy the camera and release the current resources hold by it.
  36721. */
  36722. dispose(): void;
  36723. /**
  36724. * Gets the current object class name.
  36725. * @return the class name
  36726. */
  36727. getClassName(): string;
  36728. }
  36729. }
  36730. declare module BABYLON {
  36731. /**
  36732. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36733. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36734. */
  36735. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36736. /**
  36737. * Gets the name of the behavior.
  36738. */
  36739. readonly name: string;
  36740. private _zoomStopsAnimation;
  36741. private _idleRotationSpeed;
  36742. private _idleRotationWaitTime;
  36743. private _idleRotationSpinupTime;
  36744. /**
  36745. * Sets the flag that indicates if user zooming should stop animation.
  36746. */
  36747. /**
  36748. * Gets the flag that indicates if user zooming should stop animation.
  36749. */
  36750. zoomStopsAnimation: boolean;
  36751. /**
  36752. * Sets the default speed at which the camera rotates around the model.
  36753. */
  36754. /**
  36755. * Gets the default speed at which the camera rotates around the model.
  36756. */
  36757. idleRotationSpeed: number;
  36758. /**
  36759. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36760. */
  36761. /**
  36762. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36763. */
  36764. idleRotationWaitTime: number;
  36765. /**
  36766. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36767. */
  36768. /**
  36769. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36770. */
  36771. idleRotationSpinupTime: number;
  36772. /**
  36773. * Gets a value indicating if the camera is currently rotating because of this behavior
  36774. */
  36775. readonly rotationInProgress: boolean;
  36776. private _onPrePointerObservableObserver;
  36777. private _onAfterCheckInputsObserver;
  36778. private _attachedCamera;
  36779. private _isPointerDown;
  36780. private _lastFrameTime;
  36781. private _lastInteractionTime;
  36782. private _cameraRotationSpeed;
  36783. /**
  36784. * Initializes the behavior.
  36785. */
  36786. init(): void;
  36787. /**
  36788. * Attaches the behavior to its arc rotate camera.
  36789. * @param camera Defines the camera to attach the behavior to
  36790. */
  36791. attach(camera: ArcRotateCamera): void;
  36792. /**
  36793. * Detaches the behavior from its current arc rotate camera.
  36794. */
  36795. detach(): void;
  36796. /**
  36797. * Returns true if user is scrolling.
  36798. * @return true if user is scrolling.
  36799. */
  36800. private _userIsZooming;
  36801. private _lastFrameRadius;
  36802. private _shouldAnimationStopForInteraction;
  36803. /**
  36804. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36805. */
  36806. private _applyUserInteraction;
  36807. private _userIsMoving;
  36808. }
  36809. }
  36810. declare module BABYLON {
  36811. /**
  36812. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36813. */
  36814. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36815. private ui;
  36816. /**
  36817. * The name of the behavior
  36818. */
  36819. name: string;
  36820. /**
  36821. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36822. */
  36823. distanceAwayFromFace: number;
  36824. /**
  36825. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36826. */
  36827. distanceAwayFromBottomOfFace: number;
  36828. private _faceVectors;
  36829. private _target;
  36830. private _scene;
  36831. private _onRenderObserver;
  36832. private _tmpMatrix;
  36833. private _tmpVector;
  36834. /**
  36835. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36836. * @param ui The transform node that should be attched to the mesh
  36837. */
  36838. constructor(ui: TransformNode);
  36839. /**
  36840. * Initializes the behavior
  36841. */
  36842. init(): void;
  36843. private _closestFace;
  36844. private _zeroVector;
  36845. private _lookAtTmpMatrix;
  36846. private _lookAtToRef;
  36847. /**
  36848. * Attaches the AttachToBoxBehavior to the passed in mesh
  36849. * @param target The mesh that the specified node will be attached to
  36850. */
  36851. attach(target: Mesh): void;
  36852. /**
  36853. * Detaches the behavior from the mesh
  36854. */
  36855. detach(): void;
  36856. }
  36857. }
  36858. declare module BABYLON {
  36859. /**
  36860. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36861. */
  36862. export class FadeInOutBehavior implements Behavior<Mesh> {
  36863. /**
  36864. * Time in milliseconds to delay before fading in (Default: 0)
  36865. */
  36866. delay: number;
  36867. /**
  36868. * Time in milliseconds for the mesh to fade in (Default: 300)
  36869. */
  36870. fadeInTime: number;
  36871. private _millisecondsPerFrame;
  36872. private _hovered;
  36873. private _hoverValue;
  36874. private _ownerNode;
  36875. /**
  36876. * Instatiates the FadeInOutBehavior
  36877. */
  36878. constructor();
  36879. /**
  36880. * The name of the behavior
  36881. */
  36882. readonly name: string;
  36883. /**
  36884. * Initializes the behavior
  36885. */
  36886. init(): void;
  36887. /**
  36888. * Attaches the fade behavior on the passed in mesh
  36889. * @param ownerNode The mesh that will be faded in/out once attached
  36890. */
  36891. attach(ownerNode: Mesh): void;
  36892. /**
  36893. * Detaches the behavior from the mesh
  36894. */
  36895. detach(): void;
  36896. /**
  36897. * Triggers the mesh to begin fading in or out
  36898. * @param value if the object should fade in or out (true to fade in)
  36899. */
  36900. fadeIn(value: boolean): void;
  36901. private _update;
  36902. private _setAllVisibility;
  36903. }
  36904. }
  36905. declare module BABYLON {
  36906. /**
  36907. * Class containing a set of static utilities functions for managing Pivots
  36908. * @hidden
  36909. */
  36910. export class PivotTools {
  36911. private static _PivotCached;
  36912. private static _OldPivotPoint;
  36913. private static _PivotTranslation;
  36914. private static _PivotTmpVector;
  36915. /** @hidden */
  36916. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36917. /** @hidden */
  36918. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36919. }
  36920. }
  36921. declare module BABYLON {
  36922. /**
  36923. * Class containing static functions to help procedurally build meshes
  36924. */
  36925. export class PlaneBuilder {
  36926. /**
  36927. * Creates a plane mesh
  36928. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36929. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36930. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36931. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36932. * * 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
  36933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36934. * @param name defines the name of the mesh
  36935. * @param options defines the options used to create the mesh
  36936. * @param scene defines the hosting scene
  36937. * @returns the plane mesh
  36938. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36939. */
  36940. static CreatePlane(name: string, options: {
  36941. size?: number;
  36942. width?: number;
  36943. height?: number;
  36944. sideOrientation?: number;
  36945. frontUVs?: Vector4;
  36946. backUVs?: Vector4;
  36947. updatable?: boolean;
  36948. sourcePlane?: Plane;
  36949. }, scene?: Nullable<Scene>): Mesh;
  36950. }
  36951. }
  36952. declare module BABYLON {
  36953. /**
  36954. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36955. */
  36956. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36957. private static _AnyMouseID;
  36958. /**
  36959. * Abstract mesh the behavior is set on
  36960. */
  36961. attachedNode: AbstractMesh;
  36962. private _dragPlane;
  36963. private _scene;
  36964. private _pointerObserver;
  36965. private _beforeRenderObserver;
  36966. private static _planeScene;
  36967. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36968. /**
  36969. * 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)
  36970. */
  36971. maxDragAngle: number;
  36972. /**
  36973. * @hidden
  36974. */
  36975. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36976. /**
  36977. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36978. */
  36979. currentDraggingPointerID: number;
  36980. /**
  36981. * The last position where the pointer hit the drag plane in world space
  36982. */
  36983. lastDragPosition: Vector3;
  36984. /**
  36985. * If the behavior is currently in a dragging state
  36986. */
  36987. dragging: boolean;
  36988. /**
  36989. * 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)
  36990. */
  36991. dragDeltaRatio: number;
  36992. /**
  36993. * If the drag plane orientation should be updated during the dragging (Default: true)
  36994. */
  36995. updateDragPlane: boolean;
  36996. private _debugMode;
  36997. private _moving;
  36998. /**
  36999. * Fires each time the attached mesh is dragged with the pointer
  37000. * * delta between last drag position and current drag position in world space
  37001. * * dragDistance along the drag axis
  37002. * * dragPlaneNormal normal of the current drag plane used during the drag
  37003. * * dragPlanePoint in world space where the drag intersects the drag plane
  37004. */
  37005. onDragObservable: Observable<{
  37006. delta: Vector3;
  37007. dragPlanePoint: Vector3;
  37008. dragPlaneNormal: Vector3;
  37009. dragDistance: number;
  37010. pointerId: number;
  37011. }>;
  37012. /**
  37013. * Fires each time a drag begins (eg. mouse down on mesh)
  37014. */
  37015. onDragStartObservable: Observable<{
  37016. dragPlanePoint: Vector3;
  37017. pointerId: number;
  37018. }>;
  37019. /**
  37020. * Fires each time a drag ends (eg. mouse release after drag)
  37021. */
  37022. onDragEndObservable: Observable<{
  37023. dragPlanePoint: Vector3;
  37024. pointerId: number;
  37025. }>;
  37026. /**
  37027. * If the attached mesh should be moved when dragged
  37028. */
  37029. moveAttached: boolean;
  37030. /**
  37031. * If the drag behavior will react to drag events (Default: true)
  37032. */
  37033. enabled: boolean;
  37034. /**
  37035. * If pointer events should start and release the drag (Default: true)
  37036. */
  37037. startAndReleaseDragOnPointerEvents: boolean;
  37038. /**
  37039. * If camera controls should be detached during the drag
  37040. */
  37041. detachCameraControls: boolean;
  37042. /**
  37043. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37044. */
  37045. useObjectOrienationForDragging: boolean;
  37046. private _options;
  37047. /**
  37048. * Creates a pointer drag behavior that can be attached to a mesh
  37049. * @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)
  37050. */
  37051. constructor(options?: {
  37052. dragAxis?: Vector3;
  37053. dragPlaneNormal?: Vector3;
  37054. });
  37055. /**
  37056. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37057. */
  37058. validateDrag: (targetPosition: Vector3) => boolean;
  37059. /**
  37060. * The name of the behavior
  37061. */
  37062. readonly name: string;
  37063. /**
  37064. * Initializes the behavior
  37065. */
  37066. init(): void;
  37067. private _tmpVector;
  37068. private _alternatePickedPoint;
  37069. private _worldDragAxis;
  37070. private _targetPosition;
  37071. private _attachedElement;
  37072. /**
  37073. * Attaches the drag behavior the passed in mesh
  37074. * @param ownerNode The mesh that will be dragged around once attached
  37075. * @param predicate Predicate to use for pick filtering
  37076. */
  37077. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37078. /**
  37079. * Force relase the drag action by code.
  37080. */
  37081. releaseDrag(): void;
  37082. private _startDragRay;
  37083. private _lastPointerRay;
  37084. /**
  37085. * Simulates the start of a pointer drag event on the behavior
  37086. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37087. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37088. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37089. */
  37090. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37091. private _startDrag;
  37092. private _dragDelta;
  37093. private _moveDrag;
  37094. private _pickWithRayOnDragPlane;
  37095. private _pointA;
  37096. private _pointB;
  37097. private _pointC;
  37098. private _lineA;
  37099. private _lineB;
  37100. private _localAxis;
  37101. private _lookAt;
  37102. private _updateDragPlanePosition;
  37103. /**
  37104. * Detaches the behavior from the mesh
  37105. */
  37106. detach(): void;
  37107. }
  37108. }
  37109. declare module BABYLON {
  37110. /**
  37111. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37112. */
  37113. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37114. private _dragBehaviorA;
  37115. private _dragBehaviorB;
  37116. private _startDistance;
  37117. private _initialScale;
  37118. private _targetScale;
  37119. private _ownerNode;
  37120. private _sceneRenderObserver;
  37121. /**
  37122. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37123. */
  37124. constructor();
  37125. /**
  37126. * The name of the behavior
  37127. */
  37128. readonly name: string;
  37129. /**
  37130. * Initializes the behavior
  37131. */
  37132. init(): void;
  37133. private _getCurrentDistance;
  37134. /**
  37135. * Attaches the scale behavior the passed in mesh
  37136. * @param ownerNode The mesh that will be scaled around once attached
  37137. */
  37138. attach(ownerNode: Mesh): void;
  37139. /**
  37140. * Detaches the behavior from the mesh
  37141. */
  37142. detach(): void;
  37143. }
  37144. }
  37145. declare module BABYLON {
  37146. /**
  37147. * 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
  37148. */
  37149. export class SixDofDragBehavior implements Behavior<Mesh> {
  37150. private static _virtualScene;
  37151. private _ownerNode;
  37152. private _sceneRenderObserver;
  37153. private _scene;
  37154. private _targetPosition;
  37155. private _virtualOriginMesh;
  37156. private _virtualDragMesh;
  37157. private _pointerObserver;
  37158. private _moving;
  37159. private _startingOrientation;
  37160. /**
  37161. * 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)
  37162. */
  37163. private zDragFactor;
  37164. /**
  37165. * If the object should rotate to face the drag origin
  37166. */
  37167. rotateDraggedObject: boolean;
  37168. /**
  37169. * If the behavior is currently in a dragging state
  37170. */
  37171. dragging: boolean;
  37172. /**
  37173. * 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)
  37174. */
  37175. dragDeltaRatio: number;
  37176. /**
  37177. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37178. */
  37179. currentDraggingPointerID: number;
  37180. /**
  37181. * If camera controls should be detached during the drag
  37182. */
  37183. detachCameraControls: boolean;
  37184. /**
  37185. * Fires each time a drag starts
  37186. */
  37187. onDragStartObservable: Observable<{}>;
  37188. /**
  37189. * Fires each time a drag ends (eg. mouse release after drag)
  37190. */
  37191. onDragEndObservable: Observable<{}>;
  37192. /**
  37193. * 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
  37194. */
  37195. constructor();
  37196. /**
  37197. * The name of the behavior
  37198. */
  37199. readonly name: string;
  37200. /**
  37201. * Initializes the behavior
  37202. */
  37203. init(): void;
  37204. /**
  37205. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37206. */
  37207. private readonly _pointerCamera;
  37208. /**
  37209. * Attaches the scale behavior the passed in mesh
  37210. * @param ownerNode The mesh that will be scaled around once attached
  37211. */
  37212. attach(ownerNode: Mesh): void;
  37213. /**
  37214. * Detaches the behavior from the mesh
  37215. */
  37216. detach(): void;
  37217. }
  37218. }
  37219. declare module BABYLON {
  37220. /**
  37221. * Class used to apply inverse kinematics to bones
  37222. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37223. */
  37224. export class BoneIKController {
  37225. private static _tmpVecs;
  37226. private static _tmpQuat;
  37227. private static _tmpMats;
  37228. /**
  37229. * Gets or sets the target mesh
  37230. */
  37231. targetMesh: AbstractMesh;
  37232. /** Gets or sets the mesh used as pole */
  37233. poleTargetMesh: AbstractMesh;
  37234. /**
  37235. * Gets or sets the bone used as pole
  37236. */
  37237. poleTargetBone: Nullable<Bone>;
  37238. /**
  37239. * Gets or sets the target position
  37240. */
  37241. targetPosition: Vector3;
  37242. /**
  37243. * Gets or sets the pole target position
  37244. */
  37245. poleTargetPosition: Vector3;
  37246. /**
  37247. * Gets or sets the pole target local offset
  37248. */
  37249. poleTargetLocalOffset: Vector3;
  37250. /**
  37251. * Gets or sets the pole angle
  37252. */
  37253. poleAngle: number;
  37254. /**
  37255. * Gets or sets the mesh associated with the controller
  37256. */
  37257. mesh: AbstractMesh;
  37258. /**
  37259. * 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)
  37260. */
  37261. slerpAmount: number;
  37262. private _bone1Quat;
  37263. private _bone1Mat;
  37264. private _bone2Ang;
  37265. private _bone1;
  37266. private _bone2;
  37267. private _bone1Length;
  37268. private _bone2Length;
  37269. private _maxAngle;
  37270. private _maxReach;
  37271. private _rightHandedSystem;
  37272. private _bendAxis;
  37273. private _slerping;
  37274. private _adjustRoll;
  37275. /**
  37276. * Gets or sets maximum allowed angle
  37277. */
  37278. maxAngle: number;
  37279. /**
  37280. * Creates a new BoneIKController
  37281. * @param mesh defines the mesh to control
  37282. * @param bone defines the bone to control
  37283. * @param options defines options to set up the controller
  37284. */
  37285. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37286. targetMesh?: AbstractMesh;
  37287. poleTargetMesh?: AbstractMesh;
  37288. poleTargetBone?: Bone;
  37289. poleTargetLocalOffset?: Vector3;
  37290. poleAngle?: number;
  37291. bendAxis?: Vector3;
  37292. maxAngle?: number;
  37293. slerpAmount?: number;
  37294. });
  37295. private _setMaxAngle;
  37296. /**
  37297. * Force the controller to update the bones
  37298. */
  37299. update(): void;
  37300. }
  37301. }
  37302. declare module BABYLON {
  37303. /**
  37304. * Class used to make a bone look toward a point in space
  37305. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37306. */
  37307. export class BoneLookController {
  37308. private static _tmpVecs;
  37309. private static _tmpQuat;
  37310. private static _tmpMats;
  37311. /**
  37312. * The target Vector3 that the bone will look at
  37313. */
  37314. target: Vector3;
  37315. /**
  37316. * The mesh that the bone is attached to
  37317. */
  37318. mesh: AbstractMesh;
  37319. /**
  37320. * The bone that will be looking to the target
  37321. */
  37322. bone: Bone;
  37323. /**
  37324. * The up axis of the coordinate system that is used when the bone is rotated
  37325. */
  37326. upAxis: Vector3;
  37327. /**
  37328. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37329. */
  37330. upAxisSpace: Space;
  37331. /**
  37332. * Used to make an adjustment to the yaw of the bone
  37333. */
  37334. adjustYaw: number;
  37335. /**
  37336. * Used to make an adjustment to the pitch of the bone
  37337. */
  37338. adjustPitch: number;
  37339. /**
  37340. * Used to make an adjustment to the roll of the bone
  37341. */
  37342. adjustRoll: number;
  37343. /**
  37344. * 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)
  37345. */
  37346. slerpAmount: number;
  37347. private _minYaw;
  37348. private _maxYaw;
  37349. private _minPitch;
  37350. private _maxPitch;
  37351. private _minYawSin;
  37352. private _minYawCos;
  37353. private _maxYawSin;
  37354. private _maxYawCos;
  37355. private _midYawConstraint;
  37356. private _minPitchTan;
  37357. private _maxPitchTan;
  37358. private _boneQuat;
  37359. private _slerping;
  37360. private _transformYawPitch;
  37361. private _transformYawPitchInv;
  37362. private _firstFrameSkipped;
  37363. private _yawRange;
  37364. private _fowardAxis;
  37365. /**
  37366. * Gets or sets the minimum yaw angle that the bone can look to
  37367. */
  37368. minYaw: number;
  37369. /**
  37370. * Gets or sets the maximum yaw angle that the bone can look to
  37371. */
  37372. maxYaw: number;
  37373. /**
  37374. * Gets or sets the minimum pitch angle that the bone can look to
  37375. */
  37376. minPitch: number;
  37377. /**
  37378. * Gets or sets the maximum pitch angle that the bone can look to
  37379. */
  37380. maxPitch: number;
  37381. /**
  37382. * Create a BoneLookController
  37383. * @param mesh the mesh that the bone belongs to
  37384. * @param bone the bone that will be looking to the target
  37385. * @param target the target Vector3 to look at
  37386. * @param options optional settings:
  37387. * * maxYaw: the maximum angle the bone will yaw to
  37388. * * minYaw: the minimum angle the bone will yaw to
  37389. * * maxPitch: the maximum angle the bone will pitch to
  37390. * * minPitch: the minimum angle the bone will yaw to
  37391. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37392. * * upAxis: the up axis of the coordinate system
  37393. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37394. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37395. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37396. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37397. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37398. * * adjustRoll: used to make an adjustment to the roll of the bone
  37399. **/
  37400. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37401. maxYaw?: number;
  37402. minYaw?: number;
  37403. maxPitch?: number;
  37404. minPitch?: number;
  37405. slerpAmount?: number;
  37406. upAxis?: Vector3;
  37407. upAxisSpace?: Space;
  37408. yawAxis?: Vector3;
  37409. pitchAxis?: Vector3;
  37410. adjustYaw?: number;
  37411. adjustPitch?: number;
  37412. adjustRoll?: number;
  37413. });
  37414. /**
  37415. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37416. */
  37417. update(): void;
  37418. private _getAngleDiff;
  37419. private _getAngleBetween;
  37420. private _isAngleBetween;
  37421. }
  37422. }
  37423. declare module BABYLON {
  37424. /**
  37425. * Manage the gamepad inputs to control an arc rotate camera.
  37426. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37427. */
  37428. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37429. /**
  37430. * Defines the camera the input is attached to.
  37431. */
  37432. camera: ArcRotateCamera;
  37433. /**
  37434. * Defines the gamepad the input is gathering event from.
  37435. */
  37436. gamepad: Nullable<Gamepad>;
  37437. /**
  37438. * Defines the gamepad rotation sensiblity.
  37439. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37440. */
  37441. gamepadRotationSensibility: number;
  37442. /**
  37443. * Defines the gamepad move sensiblity.
  37444. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37445. */
  37446. gamepadMoveSensibility: number;
  37447. private _onGamepadConnectedObserver;
  37448. private _onGamepadDisconnectedObserver;
  37449. /**
  37450. * Attach the input controls to a specific dom element to get the input from.
  37451. * @param element Defines the element the controls should be listened from
  37452. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37453. */
  37454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37455. /**
  37456. * Detach the current controls from the specified dom element.
  37457. * @param element Defines the element to stop listening the inputs from
  37458. */
  37459. detachControl(element: Nullable<HTMLElement>): void;
  37460. /**
  37461. * Update the current camera state depending on the inputs that have been used this frame.
  37462. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37463. */
  37464. checkInputs(): void;
  37465. /**
  37466. * Gets the class name of the current intput.
  37467. * @returns the class name
  37468. */
  37469. getClassName(): string;
  37470. /**
  37471. * Get the friendly name associated with the input class.
  37472. * @returns the input friendly name
  37473. */
  37474. getSimpleName(): string;
  37475. }
  37476. }
  37477. declare module BABYLON {
  37478. interface ArcRotateCameraInputsManager {
  37479. /**
  37480. * Add orientation input support to the input manager.
  37481. * @returns the current input manager
  37482. */
  37483. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37484. }
  37485. /**
  37486. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37487. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37488. */
  37489. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37490. /**
  37491. * Defines the camera the input is attached to.
  37492. */
  37493. camera: ArcRotateCamera;
  37494. /**
  37495. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37496. */
  37497. alphaCorrection: number;
  37498. /**
  37499. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37500. */
  37501. gammaCorrection: number;
  37502. private _alpha;
  37503. private _gamma;
  37504. private _dirty;
  37505. private _deviceOrientationHandler;
  37506. /**
  37507. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37508. */
  37509. constructor();
  37510. /**
  37511. * Attach the input controls to a specific dom element to get the input from.
  37512. * @param element Defines the element the controls should be listened from
  37513. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37514. */
  37515. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37516. /** @hidden */
  37517. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37518. /**
  37519. * Update the current camera state depending on the inputs that have been used this frame.
  37520. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37521. */
  37522. checkInputs(): void;
  37523. /**
  37524. * Detach the current controls from the specified dom element.
  37525. * @param element Defines the element to stop listening the inputs from
  37526. */
  37527. detachControl(element: Nullable<HTMLElement>): void;
  37528. /**
  37529. * Gets the class name of the current intput.
  37530. * @returns the class name
  37531. */
  37532. getClassName(): string;
  37533. /**
  37534. * Get the friendly name associated with the input class.
  37535. * @returns the input friendly name
  37536. */
  37537. getSimpleName(): string;
  37538. }
  37539. }
  37540. declare module BABYLON {
  37541. /**
  37542. * Listen to mouse events to control the camera.
  37543. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37544. */
  37545. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37546. /**
  37547. * Defines the camera the input is attached to.
  37548. */
  37549. camera: FlyCamera;
  37550. /**
  37551. * Defines if touch is enabled. (Default is true.)
  37552. */
  37553. touchEnabled: boolean;
  37554. /**
  37555. * Defines the buttons associated with the input to handle camera rotation.
  37556. */
  37557. buttons: number[];
  37558. /**
  37559. * Assign buttons for Yaw control.
  37560. */
  37561. buttonsYaw: number[];
  37562. /**
  37563. * Assign buttons for Pitch control.
  37564. */
  37565. buttonsPitch: number[];
  37566. /**
  37567. * Assign buttons for Roll control.
  37568. */
  37569. buttonsRoll: number[];
  37570. /**
  37571. * Detect if any button is being pressed while mouse is moved.
  37572. * -1 = Mouse locked.
  37573. * 0 = Left button.
  37574. * 1 = Middle Button.
  37575. * 2 = Right Button.
  37576. */
  37577. activeButton: number;
  37578. /**
  37579. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37580. * Higher values reduce its sensitivity.
  37581. */
  37582. angularSensibility: number;
  37583. private _mousemoveCallback;
  37584. private _observer;
  37585. private _rollObserver;
  37586. private previousPosition;
  37587. private noPreventDefault;
  37588. private element;
  37589. /**
  37590. * Listen to mouse events to control the camera.
  37591. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37592. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37593. */
  37594. constructor(touchEnabled?: boolean);
  37595. /**
  37596. * Attach the mouse control to the HTML DOM element.
  37597. * @param element Defines the element that listens to the input events.
  37598. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37599. */
  37600. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37601. /**
  37602. * Detach the current controls from the specified dom element.
  37603. * @param element Defines the element to stop listening the inputs from
  37604. */
  37605. detachControl(element: Nullable<HTMLElement>): void;
  37606. /**
  37607. * Gets the class name of the current input.
  37608. * @returns the class name.
  37609. */
  37610. getClassName(): string;
  37611. /**
  37612. * Get the friendly name associated with the input class.
  37613. * @returns the input's friendly name.
  37614. */
  37615. getSimpleName(): string;
  37616. private _pointerInput;
  37617. private _onMouseMove;
  37618. /**
  37619. * Rotate camera by mouse offset.
  37620. */
  37621. private rotateCamera;
  37622. }
  37623. }
  37624. declare module BABYLON {
  37625. /**
  37626. * Default Inputs manager for the FlyCamera.
  37627. * It groups all the default supported inputs for ease of use.
  37628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37629. */
  37630. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37631. /**
  37632. * Instantiates a new FlyCameraInputsManager.
  37633. * @param camera Defines the camera the inputs belong to.
  37634. */
  37635. constructor(camera: FlyCamera);
  37636. /**
  37637. * Add keyboard input support to the input manager.
  37638. * @returns the new FlyCameraKeyboardMoveInput().
  37639. */
  37640. addKeyboard(): FlyCameraInputsManager;
  37641. /**
  37642. * Add mouse input support to the input manager.
  37643. * @param touchEnabled Enable touch screen support.
  37644. * @returns the new FlyCameraMouseInput().
  37645. */
  37646. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37647. }
  37648. }
  37649. declare module BABYLON {
  37650. /**
  37651. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37652. * such as in a 3D Space Shooter or a Flight Simulator.
  37653. */
  37654. export class FlyCamera extends TargetCamera {
  37655. /**
  37656. * Define the collision ellipsoid of the camera.
  37657. * This is helpful for simulating a camera body, like a player's body.
  37658. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37659. */
  37660. ellipsoid: Vector3;
  37661. /**
  37662. * Define an offset for the position of the ellipsoid around the camera.
  37663. * This can be helpful if the camera is attached away from the player's body center,
  37664. * such as at its head.
  37665. */
  37666. ellipsoidOffset: Vector3;
  37667. /**
  37668. * Enable or disable collisions of the camera with the rest of the scene objects.
  37669. */
  37670. checkCollisions: boolean;
  37671. /**
  37672. * Enable or disable gravity on the camera.
  37673. */
  37674. applyGravity: boolean;
  37675. /**
  37676. * Define the current direction the camera is moving to.
  37677. */
  37678. cameraDirection: Vector3;
  37679. /**
  37680. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37681. * This overrides and empties cameraRotation.
  37682. */
  37683. rotationQuaternion: Quaternion;
  37684. /**
  37685. * Track Roll to maintain the wanted Rolling when looking around.
  37686. */
  37687. _trackRoll: number;
  37688. /**
  37689. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37690. */
  37691. rollCorrect: number;
  37692. /**
  37693. * Mimic a banked turn, Rolling the camera when Yawing.
  37694. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37695. */
  37696. bankedTurn: boolean;
  37697. /**
  37698. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37699. */
  37700. bankedTurnLimit: number;
  37701. /**
  37702. * Value of 0 disables the banked Roll.
  37703. * Value of 1 is equal to the Yaw angle in radians.
  37704. */
  37705. bankedTurnMultiplier: number;
  37706. /**
  37707. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37708. */
  37709. inputs: FlyCameraInputsManager;
  37710. /**
  37711. * Gets the input sensibility for mouse input.
  37712. * Higher values reduce sensitivity.
  37713. */
  37714. /**
  37715. * Sets the input sensibility for a mouse input.
  37716. * Higher values reduce sensitivity.
  37717. */
  37718. angularSensibility: number;
  37719. /**
  37720. * Get the keys for camera movement forward.
  37721. */
  37722. /**
  37723. * Set the keys for camera movement forward.
  37724. */
  37725. keysForward: number[];
  37726. /**
  37727. * Get the keys for camera movement backward.
  37728. */
  37729. keysBackward: number[];
  37730. /**
  37731. * Get the keys for camera movement up.
  37732. */
  37733. /**
  37734. * Set the keys for camera movement up.
  37735. */
  37736. keysUp: number[];
  37737. /**
  37738. * Get the keys for camera movement down.
  37739. */
  37740. /**
  37741. * Set the keys for camera movement down.
  37742. */
  37743. keysDown: number[];
  37744. /**
  37745. * Get the keys for camera movement left.
  37746. */
  37747. /**
  37748. * Set the keys for camera movement left.
  37749. */
  37750. keysLeft: number[];
  37751. /**
  37752. * Set the keys for camera movement right.
  37753. */
  37754. /**
  37755. * Set the keys for camera movement right.
  37756. */
  37757. keysRight: number[];
  37758. /**
  37759. * Event raised when the camera collides with a mesh in the scene.
  37760. */
  37761. onCollide: (collidedMesh: AbstractMesh) => void;
  37762. private _collider;
  37763. private _needMoveForGravity;
  37764. private _oldPosition;
  37765. private _diffPosition;
  37766. private _newPosition;
  37767. /** @hidden */
  37768. _localDirection: Vector3;
  37769. /** @hidden */
  37770. _transformedDirection: Vector3;
  37771. /**
  37772. * Instantiates a FlyCamera.
  37773. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37774. * such as in a 3D Space Shooter or a Flight Simulator.
  37775. * @param name Define the name of the camera in the scene.
  37776. * @param position Define the starting position of the camera in the scene.
  37777. * @param scene Define the scene the camera belongs to.
  37778. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37779. */
  37780. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37781. /**
  37782. * Attach a control to the HTML DOM element.
  37783. * @param element Defines the element that listens to the input events.
  37784. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37785. */
  37786. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37787. /**
  37788. * Detach a control from the HTML DOM element.
  37789. * The camera will stop reacting to that input.
  37790. * @param element Defines the element that listens to the input events.
  37791. */
  37792. detachControl(element: HTMLElement): void;
  37793. private _collisionMask;
  37794. /**
  37795. * Get the mask that the camera ignores in collision events.
  37796. */
  37797. /**
  37798. * Set the mask that the camera ignores in collision events.
  37799. */
  37800. collisionMask: number;
  37801. /** @hidden */
  37802. _collideWithWorld(displacement: Vector3): void;
  37803. /** @hidden */
  37804. private _onCollisionPositionChange;
  37805. /** @hidden */
  37806. _checkInputs(): void;
  37807. /** @hidden */
  37808. _decideIfNeedsToMove(): boolean;
  37809. /** @hidden */
  37810. _updatePosition(): void;
  37811. /**
  37812. * Restore the Roll to its target value at the rate specified.
  37813. * @param rate - Higher means slower restoring.
  37814. * @hidden
  37815. */
  37816. restoreRoll(rate: number): void;
  37817. /**
  37818. * Destroy the camera and release the current resources held by it.
  37819. */
  37820. dispose(): void;
  37821. /**
  37822. * Get the current object class name.
  37823. * @returns the class name.
  37824. */
  37825. getClassName(): string;
  37826. }
  37827. }
  37828. declare module BABYLON {
  37829. /**
  37830. * Listen to keyboard events to control the camera.
  37831. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37832. */
  37833. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37834. /**
  37835. * Defines the camera the input is attached to.
  37836. */
  37837. camera: FlyCamera;
  37838. /**
  37839. * The list of keyboard keys used to control the forward move of the camera.
  37840. */
  37841. keysForward: number[];
  37842. /**
  37843. * The list of keyboard keys used to control the backward move of the camera.
  37844. */
  37845. keysBackward: number[];
  37846. /**
  37847. * The list of keyboard keys used to control the forward move of the camera.
  37848. */
  37849. keysUp: number[];
  37850. /**
  37851. * The list of keyboard keys used to control the backward move of the camera.
  37852. */
  37853. keysDown: number[];
  37854. /**
  37855. * The list of keyboard keys used to control the right strafe move of the camera.
  37856. */
  37857. keysRight: number[];
  37858. /**
  37859. * The list of keyboard keys used to control the left strafe move of the camera.
  37860. */
  37861. keysLeft: number[];
  37862. private _keys;
  37863. private _onCanvasBlurObserver;
  37864. private _onKeyboardObserver;
  37865. private _engine;
  37866. private _scene;
  37867. /**
  37868. * Attach the input controls to a specific dom element to get the input from.
  37869. * @param element Defines the element the controls should be listened from
  37870. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37871. */
  37872. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37873. /**
  37874. * Detach the current controls from the specified dom element.
  37875. * @param element Defines the element to stop listening the inputs from
  37876. */
  37877. detachControl(element: Nullable<HTMLElement>): void;
  37878. /**
  37879. * Gets the class name of the current intput.
  37880. * @returns the class name
  37881. */
  37882. getClassName(): string;
  37883. /** @hidden */
  37884. _onLostFocus(e: FocusEvent): void;
  37885. /**
  37886. * Get the friendly name associated with the input class.
  37887. * @returns the input friendly name
  37888. */
  37889. getSimpleName(): string;
  37890. /**
  37891. * Update the current camera state depending on the inputs that have been used this frame.
  37892. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37893. */
  37894. checkInputs(): void;
  37895. }
  37896. }
  37897. declare module BABYLON {
  37898. /**
  37899. * Manage the mouse wheel inputs to control a follow camera.
  37900. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37901. */
  37902. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37903. /**
  37904. * Defines the camera the input is attached to.
  37905. */
  37906. camera: FollowCamera;
  37907. /**
  37908. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37909. */
  37910. axisControlRadius: boolean;
  37911. /**
  37912. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37913. */
  37914. axisControlHeight: boolean;
  37915. /**
  37916. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37917. */
  37918. axisControlRotation: boolean;
  37919. /**
  37920. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37921. * relation to mouseWheel events.
  37922. */
  37923. wheelPrecision: number;
  37924. /**
  37925. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37926. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37927. */
  37928. wheelDeltaPercentage: number;
  37929. private _wheel;
  37930. private _observer;
  37931. /**
  37932. * Attach the input controls to a specific dom element to get the input from.
  37933. * @param element Defines the element the controls should be listened from
  37934. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37935. */
  37936. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37937. /**
  37938. * Detach the current controls from the specified dom element.
  37939. * @param element Defines the element to stop listening the inputs from
  37940. */
  37941. detachControl(element: Nullable<HTMLElement>): void;
  37942. /**
  37943. * Gets the class name of the current intput.
  37944. * @returns the class name
  37945. */
  37946. getClassName(): string;
  37947. /**
  37948. * Get the friendly name associated with the input class.
  37949. * @returns the input friendly name
  37950. */
  37951. getSimpleName(): string;
  37952. }
  37953. }
  37954. declare module BABYLON {
  37955. /**
  37956. * Manage the pointers inputs to control an follow camera.
  37957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37958. */
  37959. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37960. /**
  37961. * Defines the camera the input is attached to.
  37962. */
  37963. camera: FollowCamera;
  37964. /**
  37965. * Gets the class name of the current input.
  37966. * @returns the class name
  37967. */
  37968. getClassName(): string;
  37969. /**
  37970. * Defines the pointer angular sensibility along the X axis or how fast is
  37971. * the camera rotating.
  37972. * A negative number will reverse the axis direction.
  37973. */
  37974. angularSensibilityX: number;
  37975. /**
  37976. * Defines the pointer angular sensibility along the Y axis or how fast is
  37977. * the camera rotating.
  37978. * A negative number will reverse the axis direction.
  37979. */
  37980. angularSensibilityY: number;
  37981. /**
  37982. * Defines the pointer pinch precision or how fast is the camera zooming.
  37983. * A negative number will reverse the axis direction.
  37984. */
  37985. pinchPrecision: number;
  37986. /**
  37987. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37988. * from 0.
  37989. * It defines the percentage of current camera.radius to use as delta when
  37990. * pinch zoom is used.
  37991. */
  37992. pinchDeltaPercentage: number;
  37993. /**
  37994. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37995. */
  37996. axisXControlRadius: boolean;
  37997. /**
  37998. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37999. */
  38000. axisXControlHeight: boolean;
  38001. /**
  38002. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38003. */
  38004. axisXControlRotation: boolean;
  38005. /**
  38006. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38007. */
  38008. axisYControlRadius: boolean;
  38009. /**
  38010. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38011. */
  38012. axisYControlHeight: boolean;
  38013. /**
  38014. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38015. */
  38016. axisYControlRotation: boolean;
  38017. /**
  38018. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38019. */
  38020. axisPinchControlRadius: boolean;
  38021. /**
  38022. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38023. */
  38024. axisPinchControlHeight: boolean;
  38025. /**
  38026. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38027. */
  38028. axisPinchControlRotation: boolean;
  38029. /**
  38030. * Log error messages if basic misconfiguration has occurred.
  38031. */
  38032. warningEnable: boolean;
  38033. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38034. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38035. private _warningCounter;
  38036. private _warning;
  38037. }
  38038. }
  38039. declare module BABYLON {
  38040. /**
  38041. * Default Inputs manager for the FollowCamera.
  38042. * It groups all the default supported inputs for ease of use.
  38043. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38044. */
  38045. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38046. /**
  38047. * Instantiates a new FollowCameraInputsManager.
  38048. * @param camera Defines the camera the inputs belong to
  38049. */
  38050. constructor(camera: FollowCamera);
  38051. /**
  38052. * Add keyboard input support to the input manager.
  38053. * @returns the current input manager
  38054. */
  38055. addKeyboard(): FollowCameraInputsManager;
  38056. /**
  38057. * Add mouse wheel input support to the input manager.
  38058. * @returns the current input manager
  38059. */
  38060. addMouseWheel(): FollowCameraInputsManager;
  38061. /**
  38062. * Add pointers input support to the input manager.
  38063. * @returns the current input manager
  38064. */
  38065. addPointers(): FollowCameraInputsManager;
  38066. /**
  38067. * Add orientation input support to the input manager.
  38068. * @returns the current input manager
  38069. */
  38070. addVRDeviceOrientation(): FollowCameraInputsManager;
  38071. }
  38072. }
  38073. declare module BABYLON {
  38074. /**
  38075. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38076. * an arc rotate version arcFollowCamera are available.
  38077. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38078. */
  38079. export class FollowCamera extends TargetCamera {
  38080. /**
  38081. * Distance the follow camera should follow an object at
  38082. */
  38083. radius: number;
  38084. /**
  38085. * Minimum allowed distance of the camera to the axis of rotation
  38086. * (The camera can not get closer).
  38087. * This can help limiting how the Camera is able to move in the scene.
  38088. */
  38089. lowerRadiusLimit: Nullable<number>;
  38090. /**
  38091. * Maximum allowed distance of the camera to the axis of rotation
  38092. * (The camera can not get further).
  38093. * This can help limiting how the Camera is able to move in the scene.
  38094. */
  38095. upperRadiusLimit: Nullable<number>;
  38096. /**
  38097. * Define a rotation offset between the camera and the object it follows
  38098. */
  38099. rotationOffset: number;
  38100. /**
  38101. * Minimum allowed angle to camera position relative to target object.
  38102. * This can help limiting how the Camera is able to move in the scene.
  38103. */
  38104. lowerRotationOffsetLimit: Nullable<number>;
  38105. /**
  38106. * Maximum allowed angle to camera position relative to target object.
  38107. * This can help limiting how the Camera is able to move in the scene.
  38108. */
  38109. upperRotationOffsetLimit: Nullable<number>;
  38110. /**
  38111. * Define a height offset between the camera and the object it follows.
  38112. * It can help following an object from the top (like a car chaing a plane)
  38113. */
  38114. heightOffset: number;
  38115. /**
  38116. * Minimum allowed height of camera position relative to target object.
  38117. * This can help limiting how the Camera is able to move in the scene.
  38118. */
  38119. lowerHeightOffsetLimit: Nullable<number>;
  38120. /**
  38121. * Maximum allowed height of camera position relative to target object.
  38122. * This can help limiting how the Camera is able to move in the scene.
  38123. */
  38124. upperHeightOffsetLimit: Nullable<number>;
  38125. /**
  38126. * Define how fast the camera can accelerate to follow it s target.
  38127. */
  38128. cameraAcceleration: number;
  38129. /**
  38130. * Define the speed limit of the camera following an object.
  38131. */
  38132. maxCameraSpeed: number;
  38133. /**
  38134. * Define the target of the camera.
  38135. */
  38136. lockedTarget: Nullable<AbstractMesh>;
  38137. /**
  38138. * Defines the input associated with the camera.
  38139. */
  38140. inputs: FollowCameraInputsManager;
  38141. /**
  38142. * Instantiates the follow camera.
  38143. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38144. * @param name Define the name of the camera in the scene
  38145. * @param position Define the position of the camera
  38146. * @param scene Define the scene the camera belong to
  38147. * @param lockedTarget Define the target of the camera
  38148. */
  38149. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38150. private _follow;
  38151. /**
  38152. * Attached controls to the current camera.
  38153. * @param element Defines the element the controls should be listened from
  38154. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38155. */
  38156. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38157. /**
  38158. * Detach the current controls from the camera.
  38159. * The camera will stop reacting to inputs.
  38160. * @param element Defines the element to stop listening the inputs from
  38161. */
  38162. detachControl(element: HTMLElement): void;
  38163. /** @hidden */
  38164. _checkInputs(): void;
  38165. private _checkLimits;
  38166. /**
  38167. * Gets the camera class name.
  38168. * @returns the class name
  38169. */
  38170. getClassName(): string;
  38171. }
  38172. /**
  38173. * Arc Rotate version of the follow camera.
  38174. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38175. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38176. */
  38177. export class ArcFollowCamera extends TargetCamera {
  38178. /** The longitudinal angle of the camera */
  38179. alpha: number;
  38180. /** The latitudinal angle of the camera */
  38181. beta: number;
  38182. /** The radius of the camera from its target */
  38183. radius: number;
  38184. /** Define the camera target (the messh it should follow) */
  38185. target: Nullable<AbstractMesh>;
  38186. private _cartesianCoordinates;
  38187. /**
  38188. * Instantiates a new ArcFollowCamera
  38189. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38190. * @param name Define the name of the camera
  38191. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38192. * @param beta Define the rotation angle of the camera around the elevation axis
  38193. * @param radius Define the radius of the camera from its target point
  38194. * @param target Define the target of the camera
  38195. * @param scene Define the scene the camera belongs to
  38196. */
  38197. constructor(name: string,
  38198. /** The longitudinal angle of the camera */
  38199. alpha: number,
  38200. /** The latitudinal angle of the camera */
  38201. beta: number,
  38202. /** The radius of the camera from its target */
  38203. radius: number,
  38204. /** Define the camera target (the messh it should follow) */
  38205. target: Nullable<AbstractMesh>, scene: Scene);
  38206. private _follow;
  38207. /** @hidden */
  38208. _checkInputs(): void;
  38209. /**
  38210. * Returns the class name of the object.
  38211. * It is mostly used internally for serialization purposes.
  38212. */
  38213. getClassName(): string;
  38214. }
  38215. }
  38216. declare module BABYLON {
  38217. /**
  38218. * Manage the keyboard inputs to control the movement of a follow camera.
  38219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38220. */
  38221. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38222. /**
  38223. * Defines the camera the input is attached to.
  38224. */
  38225. camera: FollowCamera;
  38226. /**
  38227. * Defines the list of key codes associated with the up action (increase heightOffset)
  38228. */
  38229. keysHeightOffsetIncr: number[];
  38230. /**
  38231. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38232. */
  38233. keysHeightOffsetDecr: number[];
  38234. /**
  38235. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38236. */
  38237. keysHeightOffsetModifierAlt: boolean;
  38238. /**
  38239. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38240. */
  38241. keysHeightOffsetModifierCtrl: boolean;
  38242. /**
  38243. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38244. */
  38245. keysHeightOffsetModifierShift: boolean;
  38246. /**
  38247. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38248. */
  38249. keysRotationOffsetIncr: number[];
  38250. /**
  38251. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38252. */
  38253. keysRotationOffsetDecr: number[];
  38254. /**
  38255. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38256. */
  38257. keysRotationOffsetModifierAlt: boolean;
  38258. /**
  38259. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38260. */
  38261. keysRotationOffsetModifierCtrl: boolean;
  38262. /**
  38263. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38264. */
  38265. keysRotationOffsetModifierShift: boolean;
  38266. /**
  38267. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38268. */
  38269. keysRadiusIncr: number[];
  38270. /**
  38271. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38272. */
  38273. keysRadiusDecr: number[];
  38274. /**
  38275. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38276. */
  38277. keysRadiusModifierAlt: boolean;
  38278. /**
  38279. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38280. */
  38281. keysRadiusModifierCtrl: boolean;
  38282. /**
  38283. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38284. */
  38285. keysRadiusModifierShift: boolean;
  38286. /**
  38287. * Defines the rate of change of heightOffset.
  38288. */
  38289. heightSensibility: number;
  38290. /**
  38291. * Defines the rate of change of rotationOffset.
  38292. */
  38293. rotationSensibility: number;
  38294. /**
  38295. * Defines the rate of change of radius.
  38296. */
  38297. radiusSensibility: number;
  38298. private _keys;
  38299. private _ctrlPressed;
  38300. private _altPressed;
  38301. private _shiftPressed;
  38302. private _onCanvasBlurObserver;
  38303. private _onKeyboardObserver;
  38304. private _engine;
  38305. private _scene;
  38306. /**
  38307. * Attach the input controls to a specific dom element to get the input from.
  38308. * @param element Defines the element the controls should be listened from
  38309. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38310. */
  38311. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38312. /**
  38313. * Detach the current controls from the specified dom element.
  38314. * @param element Defines the element to stop listening the inputs from
  38315. */
  38316. detachControl(element: Nullable<HTMLElement>): void;
  38317. /**
  38318. * Update the current camera state depending on the inputs that have been used this frame.
  38319. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38320. */
  38321. checkInputs(): void;
  38322. /**
  38323. * Gets the class name of the current input.
  38324. * @returns the class name
  38325. */
  38326. getClassName(): string;
  38327. /**
  38328. * Get the friendly name associated with the input class.
  38329. * @returns the input friendly name
  38330. */
  38331. getSimpleName(): string;
  38332. /**
  38333. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38334. * allow modification of the heightOffset value.
  38335. */
  38336. private _modifierHeightOffset;
  38337. /**
  38338. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38339. * allow modification of the rotationOffset value.
  38340. */
  38341. private _modifierRotationOffset;
  38342. /**
  38343. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38344. * allow modification of the radius value.
  38345. */
  38346. private _modifierRadius;
  38347. }
  38348. }
  38349. declare module BABYLON {
  38350. interface FreeCameraInputsManager {
  38351. /**
  38352. * @hidden
  38353. */
  38354. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38355. /**
  38356. * Add orientation input support to the input manager.
  38357. * @returns the current input manager
  38358. */
  38359. addDeviceOrientation(): FreeCameraInputsManager;
  38360. }
  38361. /**
  38362. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38363. * Screen rotation is taken into account.
  38364. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38365. */
  38366. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38367. private _camera;
  38368. private _screenOrientationAngle;
  38369. private _constantTranform;
  38370. private _screenQuaternion;
  38371. private _alpha;
  38372. private _beta;
  38373. private _gamma;
  38374. /**
  38375. * Can be used to detect if a device orientation sensor is availible on a device
  38376. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38377. * @returns a promise that will resolve on orientation change
  38378. */
  38379. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38380. /**
  38381. * @hidden
  38382. */
  38383. _onDeviceOrientationChangedObservable: Observable<void>;
  38384. /**
  38385. * Instantiates a new input
  38386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38387. */
  38388. constructor();
  38389. /**
  38390. * Define the camera controlled by the input.
  38391. */
  38392. camera: FreeCamera;
  38393. /**
  38394. * Attach the input controls to a specific dom element to get the input from.
  38395. * @param element Defines the element the controls should be listened from
  38396. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38397. */
  38398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38399. private _orientationChanged;
  38400. private _deviceOrientation;
  38401. /**
  38402. * Detach the current controls from the specified dom element.
  38403. * @param element Defines the element to stop listening the inputs from
  38404. */
  38405. detachControl(element: Nullable<HTMLElement>): void;
  38406. /**
  38407. * Update the current camera state depending on the inputs that have been used this frame.
  38408. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38409. */
  38410. checkInputs(): void;
  38411. /**
  38412. * Gets the class name of the current intput.
  38413. * @returns the class name
  38414. */
  38415. getClassName(): string;
  38416. /**
  38417. * Get the friendly name associated with the input class.
  38418. * @returns the input friendly name
  38419. */
  38420. getSimpleName(): string;
  38421. }
  38422. }
  38423. declare module BABYLON {
  38424. /**
  38425. * Manage the gamepad inputs to control a free camera.
  38426. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38427. */
  38428. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38429. /**
  38430. * Define the camera the input is attached to.
  38431. */
  38432. camera: FreeCamera;
  38433. /**
  38434. * Define the Gamepad controlling the input
  38435. */
  38436. gamepad: Nullable<Gamepad>;
  38437. /**
  38438. * Defines the gamepad rotation sensiblity.
  38439. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38440. */
  38441. gamepadAngularSensibility: number;
  38442. /**
  38443. * Defines the gamepad move sensiblity.
  38444. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38445. */
  38446. gamepadMoveSensibility: number;
  38447. private _onGamepadConnectedObserver;
  38448. private _onGamepadDisconnectedObserver;
  38449. private _cameraTransform;
  38450. private _deltaTransform;
  38451. private _vector3;
  38452. private _vector2;
  38453. /**
  38454. * Attach the input controls to a specific dom element to get the input from.
  38455. * @param element Defines the element the controls should be listened from
  38456. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38457. */
  38458. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38459. /**
  38460. * Detach the current controls from the specified dom element.
  38461. * @param element Defines the element to stop listening the inputs from
  38462. */
  38463. detachControl(element: Nullable<HTMLElement>): void;
  38464. /**
  38465. * Update the current camera state depending on the inputs that have been used this frame.
  38466. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38467. */
  38468. checkInputs(): void;
  38469. /**
  38470. * Gets the class name of the current intput.
  38471. * @returns the class name
  38472. */
  38473. getClassName(): string;
  38474. /**
  38475. * Get the friendly name associated with the input class.
  38476. * @returns the input friendly name
  38477. */
  38478. getSimpleName(): string;
  38479. }
  38480. }
  38481. declare module BABYLON {
  38482. /**
  38483. * Defines the potential axis of a Joystick
  38484. */
  38485. export enum JoystickAxis {
  38486. /** X axis */
  38487. X = 0,
  38488. /** Y axis */
  38489. Y = 1,
  38490. /** Z axis */
  38491. Z = 2
  38492. }
  38493. /**
  38494. * Class used to define virtual joystick (used in touch mode)
  38495. */
  38496. export class VirtualJoystick {
  38497. /**
  38498. * Gets or sets a boolean indicating that left and right values must be inverted
  38499. */
  38500. reverseLeftRight: boolean;
  38501. /**
  38502. * Gets or sets a boolean indicating that up and down values must be inverted
  38503. */
  38504. reverseUpDown: boolean;
  38505. /**
  38506. * Gets the offset value for the position (ie. the change of the position value)
  38507. */
  38508. deltaPosition: Vector3;
  38509. /**
  38510. * Gets a boolean indicating if the virtual joystick was pressed
  38511. */
  38512. pressed: boolean;
  38513. /**
  38514. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38515. */
  38516. static Canvas: Nullable<HTMLCanvasElement>;
  38517. private static _globalJoystickIndex;
  38518. private static vjCanvasContext;
  38519. private static vjCanvasWidth;
  38520. private static vjCanvasHeight;
  38521. private static halfWidth;
  38522. private _action;
  38523. private _axisTargetedByLeftAndRight;
  38524. private _axisTargetedByUpAndDown;
  38525. private _joystickSensibility;
  38526. private _inversedSensibility;
  38527. private _joystickPointerID;
  38528. private _joystickColor;
  38529. private _joystickPointerPos;
  38530. private _joystickPreviousPointerPos;
  38531. private _joystickPointerStartPos;
  38532. private _deltaJoystickVector;
  38533. private _leftJoystick;
  38534. private _touches;
  38535. private _onPointerDownHandlerRef;
  38536. private _onPointerMoveHandlerRef;
  38537. private _onPointerUpHandlerRef;
  38538. private _onResize;
  38539. /**
  38540. * Creates a new virtual joystick
  38541. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38542. */
  38543. constructor(leftJoystick?: boolean);
  38544. /**
  38545. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38546. * @param newJoystickSensibility defines the new sensibility
  38547. */
  38548. setJoystickSensibility(newJoystickSensibility: number): void;
  38549. private _onPointerDown;
  38550. private _onPointerMove;
  38551. private _onPointerUp;
  38552. /**
  38553. * Change the color of the virtual joystick
  38554. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38555. */
  38556. setJoystickColor(newColor: string): void;
  38557. /**
  38558. * Defines a callback to call when the joystick is touched
  38559. * @param action defines the callback
  38560. */
  38561. setActionOnTouch(action: () => any): void;
  38562. /**
  38563. * Defines which axis you'd like to control for left & right
  38564. * @param axis defines the axis to use
  38565. */
  38566. setAxisForLeftRight(axis: JoystickAxis): void;
  38567. /**
  38568. * Defines which axis you'd like to control for up & down
  38569. * @param axis defines the axis to use
  38570. */
  38571. setAxisForUpDown(axis: JoystickAxis): void;
  38572. private _drawVirtualJoystick;
  38573. /**
  38574. * Release internal HTML canvas
  38575. */
  38576. releaseCanvas(): void;
  38577. }
  38578. }
  38579. declare module BABYLON {
  38580. interface FreeCameraInputsManager {
  38581. /**
  38582. * Add virtual joystick input support to the input manager.
  38583. * @returns the current input manager
  38584. */
  38585. addVirtualJoystick(): FreeCameraInputsManager;
  38586. }
  38587. /**
  38588. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38589. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38590. */
  38591. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38592. /**
  38593. * Defines the camera the input is attached to.
  38594. */
  38595. camera: FreeCamera;
  38596. private _leftjoystick;
  38597. private _rightjoystick;
  38598. /**
  38599. * Gets the left stick of the virtual joystick.
  38600. * @returns The virtual Joystick
  38601. */
  38602. getLeftJoystick(): VirtualJoystick;
  38603. /**
  38604. * Gets the right stick of the virtual joystick.
  38605. * @returns The virtual Joystick
  38606. */
  38607. getRightJoystick(): VirtualJoystick;
  38608. /**
  38609. * Update the current camera state depending on the inputs that have been used this frame.
  38610. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38611. */
  38612. checkInputs(): void;
  38613. /**
  38614. * Attach the input controls to a specific dom element to get the input from.
  38615. * @param element Defines the element the controls should be listened from
  38616. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38617. */
  38618. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38619. /**
  38620. * Detach the current controls from the specified dom element.
  38621. * @param element Defines the element to stop listening the inputs from
  38622. */
  38623. detachControl(element: Nullable<HTMLElement>): void;
  38624. /**
  38625. * Gets the class name of the current intput.
  38626. * @returns the class name
  38627. */
  38628. getClassName(): string;
  38629. /**
  38630. * Get the friendly name associated with the input class.
  38631. * @returns the input friendly name
  38632. */
  38633. getSimpleName(): string;
  38634. }
  38635. }
  38636. declare module BABYLON {
  38637. /**
  38638. * This represents a FPS type of camera controlled by touch.
  38639. * This is like a universal camera minus the Gamepad controls.
  38640. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38641. */
  38642. export class TouchCamera extends FreeCamera {
  38643. /**
  38644. * Defines the touch sensibility for rotation.
  38645. * The higher the faster.
  38646. */
  38647. touchAngularSensibility: number;
  38648. /**
  38649. * Defines the touch sensibility for move.
  38650. * The higher the faster.
  38651. */
  38652. touchMoveSensibility: number;
  38653. /**
  38654. * Instantiates a new touch camera.
  38655. * This represents a FPS type of camera controlled by touch.
  38656. * This is like a universal camera minus the Gamepad controls.
  38657. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38658. * @param name Define the name of the camera in the scene
  38659. * @param position Define the start position of the camera in the scene
  38660. * @param scene Define the scene the camera belongs to
  38661. */
  38662. constructor(name: string, position: Vector3, scene: Scene);
  38663. /**
  38664. * Gets the current object class name.
  38665. * @return the class name
  38666. */
  38667. getClassName(): string;
  38668. /** @hidden */
  38669. _setupInputs(): void;
  38670. }
  38671. }
  38672. declare module BABYLON {
  38673. /**
  38674. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38675. * being tilted forward or back and left or right.
  38676. */
  38677. export class DeviceOrientationCamera extends FreeCamera {
  38678. private _initialQuaternion;
  38679. private _quaternionCache;
  38680. private _tmpDragQuaternion;
  38681. private _disablePointerInputWhenUsingDeviceOrientation;
  38682. /**
  38683. * Creates a new device orientation camera
  38684. * @param name The name of the camera
  38685. * @param position The start position camera
  38686. * @param scene The scene the camera belongs to
  38687. */
  38688. constructor(name: string, position: Vector3, scene: Scene);
  38689. /**
  38690. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38691. */
  38692. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38693. private _dragFactor;
  38694. /**
  38695. * Enabled turning on the y axis when the orientation sensor is active
  38696. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38697. */
  38698. enableHorizontalDragging(dragFactor?: number): void;
  38699. /**
  38700. * Gets the current instance class name ("DeviceOrientationCamera").
  38701. * This helps avoiding instanceof at run time.
  38702. * @returns the class name
  38703. */
  38704. getClassName(): string;
  38705. /**
  38706. * @hidden
  38707. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38708. */
  38709. _checkInputs(): void;
  38710. /**
  38711. * Reset the camera to its default orientation on the specified axis only.
  38712. * @param axis The axis to reset
  38713. */
  38714. resetToCurrentRotation(axis?: Axis): void;
  38715. }
  38716. }
  38717. declare module BABYLON {
  38718. /**
  38719. * Defines supported buttons for XBox360 compatible gamepads
  38720. */
  38721. export enum Xbox360Button {
  38722. /** A */
  38723. A = 0,
  38724. /** B */
  38725. B = 1,
  38726. /** X */
  38727. X = 2,
  38728. /** Y */
  38729. Y = 3,
  38730. /** Start */
  38731. Start = 4,
  38732. /** Back */
  38733. Back = 5,
  38734. /** Left button */
  38735. LB = 6,
  38736. /** Right button */
  38737. RB = 7,
  38738. /** Left stick */
  38739. LeftStick = 8,
  38740. /** Right stick */
  38741. RightStick = 9
  38742. }
  38743. /** Defines values for XBox360 DPad */
  38744. export enum Xbox360Dpad {
  38745. /** Up */
  38746. Up = 0,
  38747. /** Down */
  38748. Down = 1,
  38749. /** Left */
  38750. Left = 2,
  38751. /** Right */
  38752. Right = 3
  38753. }
  38754. /**
  38755. * Defines a XBox360 gamepad
  38756. */
  38757. export class Xbox360Pad extends Gamepad {
  38758. private _leftTrigger;
  38759. private _rightTrigger;
  38760. private _onlefttriggerchanged;
  38761. private _onrighttriggerchanged;
  38762. private _onbuttondown;
  38763. private _onbuttonup;
  38764. private _ondpaddown;
  38765. private _ondpadup;
  38766. /** Observable raised when a button is pressed */
  38767. onButtonDownObservable: Observable<Xbox360Button>;
  38768. /** Observable raised when a button is released */
  38769. onButtonUpObservable: Observable<Xbox360Button>;
  38770. /** Observable raised when a pad is pressed */
  38771. onPadDownObservable: Observable<Xbox360Dpad>;
  38772. /** Observable raised when a pad is released */
  38773. onPadUpObservable: Observable<Xbox360Dpad>;
  38774. private _buttonA;
  38775. private _buttonB;
  38776. private _buttonX;
  38777. private _buttonY;
  38778. private _buttonBack;
  38779. private _buttonStart;
  38780. private _buttonLB;
  38781. private _buttonRB;
  38782. private _buttonLeftStick;
  38783. private _buttonRightStick;
  38784. private _dPadUp;
  38785. private _dPadDown;
  38786. private _dPadLeft;
  38787. private _dPadRight;
  38788. private _isXboxOnePad;
  38789. /**
  38790. * Creates a new XBox360 gamepad object
  38791. * @param id defines the id of this gamepad
  38792. * @param index defines its index
  38793. * @param gamepad defines the internal HTML gamepad object
  38794. * @param xboxOne defines if it is a XBox One gamepad
  38795. */
  38796. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38797. /**
  38798. * Defines the callback to call when left trigger is pressed
  38799. * @param callback defines the callback to use
  38800. */
  38801. onlefttriggerchanged(callback: (value: number) => void): void;
  38802. /**
  38803. * Defines the callback to call when right trigger is pressed
  38804. * @param callback defines the callback to use
  38805. */
  38806. onrighttriggerchanged(callback: (value: number) => void): void;
  38807. /**
  38808. * Gets the left trigger value
  38809. */
  38810. /**
  38811. * Sets the left trigger value
  38812. */
  38813. leftTrigger: number;
  38814. /**
  38815. * Gets the right trigger value
  38816. */
  38817. /**
  38818. * Sets the right trigger value
  38819. */
  38820. rightTrigger: number;
  38821. /**
  38822. * Defines the callback to call when a button is pressed
  38823. * @param callback defines the callback to use
  38824. */
  38825. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38826. /**
  38827. * Defines the callback to call when a button is released
  38828. * @param callback defines the callback to use
  38829. */
  38830. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38831. /**
  38832. * Defines the callback to call when a pad is pressed
  38833. * @param callback defines the callback to use
  38834. */
  38835. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38836. /**
  38837. * Defines the callback to call when a pad is released
  38838. * @param callback defines the callback to use
  38839. */
  38840. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38841. private _setButtonValue;
  38842. private _setDPadValue;
  38843. /**
  38844. * Gets the value of the `A` button
  38845. */
  38846. /**
  38847. * Sets the value of the `A` button
  38848. */
  38849. buttonA: number;
  38850. /**
  38851. * Gets the value of the `B` button
  38852. */
  38853. /**
  38854. * Sets the value of the `B` button
  38855. */
  38856. buttonB: number;
  38857. /**
  38858. * Gets the value of the `X` button
  38859. */
  38860. /**
  38861. * Sets the value of the `X` button
  38862. */
  38863. buttonX: number;
  38864. /**
  38865. * Gets the value of the `Y` button
  38866. */
  38867. /**
  38868. * Sets the value of the `Y` button
  38869. */
  38870. buttonY: number;
  38871. /**
  38872. * Gets the value of the `Start` button
  38873. */
  38874. /**
  38875. * Sets the value of the `Start` button
  38876. */
  38877. buttonStart: number;
  38878. /**
  38879. * Gets the value of the `Back` button
  38880. */
  38881. /**
  38882. * Sets the value of the `Back` button
  38883. */
  38884. buttonBack: number;
  38885. /**
  38886. * Gets the value of the `Left` button
  38887. */
  38888. /**
  38889. * Sets the value of the `Left` button
  38890. */
  38891. buttonLB: number;
  38892. /**
  38893. * Gets the value of the `Right` button
  38894. */
  38895. /**
  38896. * Sets the value of the `Right` button
  38897. */
  38898. buttonRB: number;
  38899. /**
  38900. * Gets the value of the Left joystick
  38901. */
  38902. /**
  38903. * Sets the value of the Left joystick
  38904. */
  38905. buttonLeftStick: number;
  38906. /**
  38907. * Gets the value of the Right joystick
  38908. */
  38909. /**
  38910. * Sets the value of the Right joystick
  38911. */
  38912. buttonRightStick: number;
  38913. /**
  38914. * Gets the value of D-pad up
  38915. */
  38916. /**
  38917. * Sets the value of D-pad up
  38918. */
  38919. dPadUp: number;
  38920. /**
  38921. * Gets the value of D-pad down
  38922. */
  38923. /**
  38924. * Sets the value of D-pad down
  38925. */
  38926. dPadDown: number;
  38927. /**
  38928. * Gets the value of D-pad left
  38929. */
  38930. /**
  38931. * Sets the value of D-pad left
  38932. */
  38933. dPadLeft: number;
  38934. /**
  38935. * Gets the value of D-pad right
  38936. */
  38937. /**
  38938. * Sets the value of D-pad right
  38939. */
  38940. dPadRight: number;
  38941. /**
  38942. * Force the gamepad to synchronize with device values
  38943. */
  38944. update(): void;
  38945. /**
  38946. * Disposes the gamepad
  38947. */
  38948. dispose(): void;
  38949. }
  38950. }
  38951. declare module BABYLON {
  38952. /**
  38953. * Defines supported buttons for DualShock compatible gamepads
  38954. */
  38955. export enum DualShockButton {
  38956. /** Cross */
  38957. Cross = 0,
  38958. /** Circle */
  38959. Circle = 1,
  38960. /** Square */
  38961. Square = 2,
  38962. /** Triangle */
  38963. Triangle = 3,
  38964. /** Options */
  38965. Options = 4,
  38966. /** Share */
  38967. Share = 5,
  38968. /** L1 */
  38969. L1 = 6,
  38970. /** R1 */
  38971. R1 = 7,
  38972. /** Left stick */
  38973. LeftStick = 8,
  38974. /** Right stick */
  38975. RightStick = 9
  38976. }
  38977. /** Defines values for DualShock DPad */
  38978. export enum DualShockDpad {
  38979. /** Up */
  38980. Up = 0,
  38981. /** Down */
  38982. Down = 1,
  38983. /** Left */
  38984. Left = 2,
  38985. /** Right */
  38986. Right = 3
  38987. }
  38988. /**
  38989. * Defines a DualShock gamepad
  38990. */
  38991. export class DualShockPad extends Gamepad {
  38992. private _leftTrigger;
  38993. private _rightTrigger;
  38994. private _onlefttriggerchanged;
  38995. private _onrighttriggerchanged;
  38996. private _onbuttondown;
  38997. private _onbuttonup;
  38998. private _ondpaddown;
  38999. private _ondpadup;
  39000. /** Observable raised when a button is pressed */
  39001. onButtonDownObservable: Observable<DualShockButton>;
  39002. /** Observable raised when a button is released */
  39003. onButtonUpObservable: Observable<DualShockButton>;
  39004. /** Observable raised when a pad is pressed */
  39005. onPadDownObservable: Observable<DualShockDpad>;
  39006. /** Observable raised when a pad is released */
  39007. onPadUpObservable: Observable<DualShockDpad>;
  39008. private _buttonCross;
  39009. private _buttonCircle;
  39010. private _buttonSquare;
  39011. private _buttonTriangle;
  39012. private _buttonShare;
  39013. private _buttonOptions;
  39014. private _buttonL1;
  39015. private _buttonR1;
  39016. private _buttonLeftStick;
  39017. private _buttonRightStick;
  39018. private _dPadUp;
  39019. private _dPadDown;
  39020. private _dPadLeft;
  39021. private _dPadRight;
  39022. /**
  39023. * Creates a new DualShock gamepad object
  39024. * @param id defines the id of this gamepad
  39025. * @param index defines its index
  39026. * @param gamepad defines the internal HTML gamepad object
  39027. */
  39028. constructor(id: string, index: number, gamepad: any);
  39029. /**
  39030. * Defines the callback to call when left trigger is pressed
  39031. * @param callback defines the callback to use
  39032. */
  39033. onlefttriggerchanged(callback: (value: number) => void): void;
  39034. /**
  39035. * Defines the callback to call when right trigger is pressed
  39036. * @param callback defines the callback to use
  39037. */
  39038. onrighttriggerchanged(callback: (value: number) => void): void;
  39039. /**
  39040. * Gets the left trigger value
  39041. */
  39042. /**
  39043. * Sets the left trigger value
  39044. */
  39045. leftTrigger: number;
  39046. /**
  39047. * Gets the right trigger value
  39048. */
  39049. /**
  39050. * Sets the right trigger value
  39051. */
  39052. rightTrigger: number;
  39053. /**
  39054. * Defines the callback to call when a button is pressed
  39055. * @param callback defines the callback to use
  39056. */
  39057. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39058. /**
  39059. * Defines the callback to call when a button is released
  39060. * @param callback defines the callback to use
  39061. */
  39062. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39063. /**
  39064. * Defines the callback to call when a pad is pressed
  39065. * @param callback defines the callback to use
  39066. */
  39067. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39068. /**
  39069. * Defines the callback to call when a pad is released
  39070. * @param callback defines the callback to use
  39071. */
  39072. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39073. private _setButtonValue;
  39074. private _setDPadValue;
  39075. /**
  39076. * Gets the value of the `Cross` button
  39077. */
  39078. /**
  39079. * Sets the value of the `Cross` button
  39080. */
  39081. buttonCross: number;
  39082. /**
  39083. * Gets the value of the `Circle` button
  39084. */
  39085. /**
  39086. * Sets the value of the `Circle` button
  39087. */
  39088. buttonCircle: number;
  39089. /**
  39090. * Gets the value of the `Square` button
  39091. */
  39092. /**
  39093. * Sets the value of the `Square` button
  39094. */
  39095. buttonSquare: number;
  39096. /**
  39097. * Gets the value of the `Triangle` button
  39098. */
  39099. /**
  39100. * Sets the value of the `Triangle` button
  39101. */
  39102. buttonTriangle: number;
  39103. /**
  39104. * Gets the value of the `Options` button
  39105. */
  39106. /**
  39107. * Sets the value of the `Options` button
  39108. */
  39109. buttonOptions: number;
  39110. /**
  39111. * Gets the value of the `Share` button
  39112. */
  39113. /**
  39114. * Sets the value of the `Share` button
  39115. */
  39116. buttonShare: number;
  39117. /**
  39118. * Gets the value of the `L1` button
  39119. */
  39120. /**
  39121. * Sets the value of the `L1` button
  39122. */
  39123. buttonL1: number;
  39124. /**
  39125. * Gets the value of the `R1` button
  39126. */
  39127. /**
  39128. * Sets the value of the `R1` button
  39129. */
  39130. buttonR1: number;
  39131. /**
  39132. * Gets the value of the Left joystick
  39133. */
  39134. /**
  39135. * Sets the value of the Left joystick
  39136. */
  39137. buttonLeftStick: number;
  39138. /**
  39139. * Gets the value of the Right joystick
  39140. */
  39141. /**
  39142. * Sets the value of the Right joystick
  39143. */
  39144. buttonRightStick: number;
  39145. /**
  39146. * Gets the value of D-pad up
  39147. */
  39148. /**
  39149. * Sets the value of D-pad up
  39150. */
  39151. dPadUp: number;
  39152. /**
  39153. * Gets the value of D-pad down
  39154. */
  39155. /**
  39156. * Sets the value of D-pad down
  39157. */
  39158. dPadDown: number;
  39159. /**
  39160. * Gets the value of D-pad left
  39161. */
  39162. /**
  39163. * Sets the value of D-pad left
  39164. */
  39165. dPadLeft: number;
  39166. /**
  39167. * Gets the value of D-pad right
  39168. */
  39169. /**
  39170. * Sets the value of D-pad right
  39171. */
  39172. dPadRight: number;
  39173. /**
  39174. * Force the gamepad to synchronize with device values
  39175. */
  39176. update(): void;
  39177. /**
  39178. * Disposes the gamepad
  39179. */
  39180. dispose(): void;
  39181. }
  39182. }
  39183. declare module BABYLON {
  39184. /**
  39185. * Manager for handling gamepads
  39186. */
  39187. export class GamepadManager {
  39188. private _scene?;
  39189. private _babylonGamepads;
  39190. private _oneGamepadConnected;
  39191. /** @hidden */
  39192. _isMonitoring: boolean;
  39193. private _gamepadEventSupported;
  39194. private _gamepadSupport;
  39195. /**
  39196. * observable to be triggered when the gamepad controller has been connected
  39197. */
  39198. onGamepadConnectedObservable: Observable<Gamepad>;
  39199. /**
  39200. * observable to be triggered when the gamepad controller has been disconnected
  39201. */
  39202. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39203. private _onGamepadConnectedEvent;
  39204. private _onGamepadDisconnectedEvent;
  39205. /**
  39206. * Initializes the gamepad manager
  39207. * @param _scene BabylonJS scene
  39208. */
  39209. constructor(_scene?: Scene | undefined);
  39210. /**
  39211. * The gamepads in the game pad manager
  39212. */
  39213. readonly gamepads: Gamepad[];
  39214. /**
  39215. * Get the gamepad controllers based on type
  39216. * @param type The type of gamepad controller
  39217. * @returns Nullable gamepad
  39218. */
  39219. getGamepadByType(type?: number): Nullable<Gamepad>;
  39220. /**
  39221. * Disposes the gamepad manager
  39222. */
  39223. dispose(): void;
  39224. private _addNewGamepad;
  39225. private _startMonitoringGamepads;
  39226. private _stopMonitoringGamepads;
  39227. /** @hidden */
  39228. _checkGamepadsStatus(): void;
  39229. private _updateGamepadObjects;
  39230. }
  39231. }
  39232. declare module BABYLON {
  39233. interface Scene {
  39234. /** @hidden */
  39235. _gamepadManager: Nullable<GamepadManager>;
  39236. /**
  39237. * Gets the gamepad manager associated with the scene
  39238. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39239. */
  39240. gamepadManager: GamepadManager;
  39241. }
  39242. /**
  39243. * Interface representing a free camera inputs manager
  39244. */
  39245. interface FreeCameraInputsManager {
  39246. /**
  39247. * Adds gamepad input support to the FreeCameraInputsManager.
  39248. * @returns the FreeCameraInputsManager
  39249. */
  39250. addGamepad(): FreeCameraInputsManager;
  39251. }
  39252. /**
  39253. * Interface representing an arc rotate camera inputs manager
  39254. */
  39255. interface ArcRotateCameraInputsManager {
  39256. /**
  39257. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39258. * @returns the camera inputs manager
  39259. */
  39260. addGamepad(): ArcRotateCameraInputsManager;
  39261. }
  39262. /**
  39263. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39264. */
  39265. export class GamepadSystemSceneComponent implements ISceneComponent {
  39266. /**
  39267. * The component name helpfull to identify the component in the list of scene components.
  39268. */
  39269. readonly name: string;
  39270. /**
  39271. * The scene the component belongs to.
  39272. */
  39273. scene: Scene;
  39274. /**
  39275. * Creates a new instance of the component for the given scene
  39276. * @param scene Defines the scene to register the component in
  39277. */
  39278. constructor(scene: Scene);
  39279. /**
  39280. * Registers the component in a given scene
  39281. */
  39282. register(): void;
  39283. /**
  39284. * Rebuilds the elements related to this component in case of
  39285. * context lost for instance.
  39286. */
  39287. rebuild(): void;
  39288. /**
  39289. * Disposes the component and the associated ressources
  39290. */
  39291. dispose(): void;
  39292. private _beforeCameraUpdate;
  39293. }
  39294. }
  39295. declare module BABYLON {
  39296. /**
  39297. * 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,
  39298. * which still works and will still be found in many Playgrounds.
  39299. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39300. */
  39301. export class UniversalCamera extends TouchCamera {
  39302. /**
  39303. * Defines the gamepad rotation sensiblity.
  39304. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39305. */
  39306. gamepadAngularSensibility: number;
  39307. /**
  39308. * Defines the gamepad move sensiblity.
  39309. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39310. */
  39311. gamepadMoveSensibility: number;
  39312. /**
  39313. * 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,
  39314. * which still works and will still be found in many Playgrounds.
  39315. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39316. * @param name Define the name of the camera in the scene
  39317. * @param position Define the start position of the camera in the scene
  39318. * @param scene Define the scene the camera belongs to
  39319. */
  39320. constructor(name: string, position: Vector3, scene: Scene);
  39321. /**
  39322. * Gets the current object class name.
  39323. * @return the class name
  39324. */
  39325. getClassName(): string;
  39326. }
  39327. }
  39328. declare module BABYLON {
  39329. /**
  39330. * This represents a FPS type of camera. This is only here for back compat purpose.
  39331. * Please use the UniversalCamera instead as both are identical.
  39332. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39333. */
  39334. export class GamepadCamera extends UniversalCamera {
  39335. /**
  39336. * Instantiates a new Gamepad Camera
  39337. * This represents a FPS type of camera. This is only here for back compat purpose.
  39338. * Please use the UniversalCamera instead as both are identical.
  39339. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39340. * @param name Define the name of the camera in the scene
  39341. * @param position Define the start position of the camera in the scene
  39342. * @param scene Define the scene the camera belongs to
  39343. */
  39344. constructor(name: string, position: Vector3, scene: Scene);
  39345. /**
  39346. * Gets the current object class name.
  39347. * @return the class name
  39348. */
  39349. getClassName(): string;
  39350. }
  39351. }
  39352. declare module BABYLON {
  39353. /** @hidden */
  39354. export var passPixelShader: {
  39355. name: string;
  39356. shader: string;
  39357. };
  39358. }
  39359. declare module BABYLON {
  39360. /** @hidden */
  39361. export var passCubePixelShader: {
  39362. name: string;
  39363. shader: string;
  39364. };
  39365. }
  39366. declare module BABYLON {
  39367. /**
  39368. * PassPostProcess which produces an output the same as it's input
  39369. */
  39370. export class PassPostProcess extends PostProcess {
  39371. /**
  39372. * Creates the PassPostProcess
  39373. * @param name The name of the effect.
  39374. * @param options The required width/height ratio to downsize to before computing the render pass.
  39375. * @param camera The camera to apply the render pass to.
  39376. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39377. * @param engine The engine which the post process will be applied. (default: current engine)
  39378. * @param reusable If the post process can be reused on the same frame. (default: false)
  39379. * @param textureType The type of texture to be used when performing the post processing.
  39380. * @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)
  39381. */
  39382. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39383. }
  39384. /**
  39385. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39386. */
  39387. export class PassCubePostProcess extends PostProcess {
  39388. private _face;
  39389. /**
  39390. * Gets or sets the cube face to display.
  39391. * * 0 is +X
  39392. * * 1 is -X
  39393. * * 2 is +Y
  39394. * * 3 is -Y
  39395. * * 4 is +Z
  39396. * * 5 is -Z
  39397. */
  39398. face: number;
  39399. /**
  39400. * Creates the PassCubePostProcess
  39401. * @param name The name of the effect.
  39402. * @param options The required width/height ratio to downsize to before computing the render pass.
  39403. * @param camera The camera to apply the render pass to.
  39404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39405. * @param engine The engine which the post process will be applied. (default: current engine)
  39406. * @param reusable If the post process can be reused on the same frame. (default: false)
  39407. * @param textureType The type of texture to be used when performing the post processing.
  39408. * @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)
  39409. */
  39410. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39411. }
  39412. }
  39413. declare module BABYLON {
  39414. /** @hidden */
  39415. export var anaglyphPixelShader: {
  39416. name: string;
  39417. shader: string;
  39418. };
  39419. }
  39420. declare module BABYLON {
  39421. /**
  39422. * Postprocess used to generate anaglyphic rendering
  39423. */
  39424. export class AnaglyphPostProcess extends PostProcess {
  39425. private _passedProcess;
  39426. /**
  39427. * Creates a new AnaglyphPostProcess
  39428. * @param name defines postprocess name
  39429. * @param options defines creation options or target ratio scale
  39430. * @param rigCameras defines cameras using this postprocess
  39431. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39432. * @param engine defines hosting engine
  39433. * @param reusable defines if the postprocess will be reused multiple times per frame
  39434. */
  39435. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39436. }
  39437. }
  39438. declare module BABYLON {
  39439. /**
  39440. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39441. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39442. */
  39443. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39444. /**
  39445. * Creates a new AnaglyphArcRotateCamera
  39446. * @param name defines camera name
  39447. * @param alpha defines alpha angle (in radians)
  39448. * @param beta defines beta angle (in radians)
  39449. * @param radius defines radius
  39450. * @param target defines camera target
  39451. * @param interaxialDistance defines distance between each color axis
  39452. * @param scene defines the hosting scene
  39453. */
  39454. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39455. /**
  39456. * Gets camera class name
  39457. * @returns AnaglyphArcRotateCamera
  39458. */
  39459. getClassName(): string;
  39460. }
  39461. }
  39462. declare module BABYLON {
  39463. /**
  39464. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39465. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39466. */
  39467. export class AnaglyphFreeCamera extends FreeCamera {
  39468. /**
  39469. * Creates a new AnaglyphFreeCamera
  39470. * @param name defines camera name
  39471. * @param position defines initial position
  39472. * @param interaxialDistance defines distance between each color axis
  39473. * @param scene defines the hosting scene
  39474. */
  39475. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39476. /**
  39477. * Gets camera class name
  39478. * @returns AnaglyphFreeCamera
  39479. */
  39480. getClassName(): string;
  39481. }
  39482. }
  39483. declare module BABYLON {
  39484. /**
  39485. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39486. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39487. */
  39488. export class AnaglyphGamepadCamera extends GamepadCamera {
  39489. /**
  39490. * Creates a new AnaglyphGamepadCamera
  39491. * @param name defines camera name
  39492. * @param position defines initial position
  39493. * @param interaxialDistance defines distance between each color axis
  39494. * @param scene defines the hosting scene
  39495. */
  39496. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39497. /**
  39498. * Gets camera class name
  39499. * @returns AnaglyphGamepadCamera
  39500. */
  39501. getClassName(): string;
  39502. }
  39503. }
  39504. declare module BABYLON {
  39505. /**
  39506. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39507. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39508. */
  39509. export class AnaglyphUniversalCamera extends UniversalCamera {
  39510. /**
  39511. * Creates a new AnaglyphUniversalCamera
  39512. * @param name defines camera name
  39513. * @param position defines initial position
  39514. * @param interaxialDistance defines distance between each color axis
  39515. * @param scene defines the hosting scene
  39516. */
  39517. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39518. /**
  39519. * Gets camera class name
  39520. * @returns AnaglyphUniversalCamera
  39521. */
  39522. getClassName(): string;
  39523. }
  39524. }
  39525. declare module BABYLON {
  39526. /** @hidden */
  39527. export var stereoscopicInterlacePixelShader: {
  39528. name: string;
  39529. shader: string;
  39530. };
  39531. }
  39532. declare module BABYLON {
  39533. /**
  39534. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39535. */
  39536. export class StereoscopicInterlacePostProcess extends PostProcess {
  39537. private _stepSize;
  39538. private _passedProcess;
  39539. /**
  39540. * Initializes a StereoscopicInterlacePostProcess
  39541. * @param name The name of the effect.
  39542. * @param rigCameras The rig cameras to be appled to the post process
  39543. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39544. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39545. * @param engine The engine which the post process will be applied. (default: current engine)
  39546. * @param reusable If the post process can be reused on the same frame. (default: false)
  39547. */
  39548. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39549. }
  39550. }
  39551. declare module BABYLON {
  39552. /**
  39553. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39554. * @see http://doc.babylonjs.com/features/cameras
  39555. */
  39556. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39557. /**
  39558. * Creates a new StereoscopicArcRotateCamera
  39559. * @param name defines camera name
  39560. * @param alpha defines alpha angle (in radians)
  39561. * @param beta defines beta angle (in radians)
  39562. * @param radius defines radius
  39563. * @param target defines camera target
  39564. * @param interaxialDistance defines distance between each color axis
  39565. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39566. * @param scene defines the hosting scene
  39567. */
  39568. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39569. /**
  39570. * Gets camera class name
  39571. * @returns StereoscopicArcRotateCamera
  39572. */
  39573. getClassName(): string;
  39574. }
  39575. }
  39576. declare module BABYLON {
  39577. /**
  39578. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39579. * @see http://doc.babylonjs.com/features/cameras
  39580. */
  39581. export class StereoscopicFreeCamera extends FreeCamera {
  39582. /**
  39583. * Creates a new StereoscopicFreeCamera
  39584. * @param name defines camera name
  39585. * @param position defines initial position
  39586. * @param interaxialDistance defines distance between each color axis
  39587. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39588. * @param scene defines the hosting scene
  39589. */
  39590. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39591. /**
  39592. * Gets camera class name
  39593. * @returns StereoscopicFreeCamera
  39594. */
  39595. getClassName(): string;
  39596. }
  39597. }
  39598. declare module BABYLON {
  39599. /**
  39600. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39601. * @see http://doc.babylonjs.com/features/cameras
  39602. */
  39603. export class StereoscopicGamepadCamera extends GamepadCamera {
  39604. /**
  39605. * Creates a new StereoscopicGamepadCamera
  39606. * @param name defines camera name
  39607. * @param position defines initial position
  39608. * @param interaxialDistance defines distance between each color axis
  39609. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39610. * @param scene defines the hosting scene
  39611. */
  39612. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39613. /**
  39614. * Gets camera class name
  39615. * @returns StereoscopicGamepadCamera
  39616. */
  39617. getClassName(): string;
  39618. }
  39619. }
  39620. declare module BABYLON {
  39621. /**
  39622. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39623. * @see http://doc.babylonjs.com/features/cameras
  39624. */
  39625. export class StereoscopicUniversalCamera extends UniversalCamera {
  39626. /**
  39627. * Creates a new StereoscopicUniversalCamera
  39628. * @param name defines camera name
  39629. * @param position defines initial position
  39630. * @param interaxialDistance defines distance between each color axis
  39631. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39632. * @param scene defines the hosting scene
  39633. */
  39634. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39635. /**
  39636. * Gets camera class name
  39637. * @returns StereoscopicUniversalCamera
  39638. */
  39639. getClassName(): string;
  39640. }
  39641. }
  39642. declare module BABYLON {
  39643. /**
  39644. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39645. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39646. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39647. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39648. */
  39649. export class VirtualJoysticksCamera extends FreeCamera {
  39650. /**
  39651. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39652. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39653. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39654. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39655. * @param name Define the name of the camera in the scene
  39656. * @param position Define the start position of the camera in the scene
  39657. * @param scene Define the scene the camera belongs to
  39658. */
  39659. constructor(name: string, position: Vector3, scene: Scene);
  39660. /**
  39661. * Gets the current object class name.
  39662. * @return the class name
  39663. */
  39664. getClassName(): string;
  39665. }
  39666. }
  39667. declare module BABYLON {
  39668. /**
  39669. * This represents all the required metrics to create a VR camera.
  39670. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39671. */
  39672. export class VRCameraMetrics {
  39673. /**
  39674. * Define the horizontal resolution off the screen.
  39675. */
  39676. hResolution: number;
  39677. /**
  39678. * Define the vertical resolution off the screen.
  39679. */
  39680. vResolution: number;
  39681. /**
  39682. * Define the horizontal screen size.
  39683. */
  39684. hScreenSize: number;
  39685. /**
  39686. * Define the vertical screen size.
  39687. */
  39688. vScreenSize: number;
  39689. /**
  39690. * Define the vertical screen center position.
  39691. */
  39692. vScreenCenter: number;
  39693. /**
  39694. * Define the distance of the eyes to the screen.
  39695. */
  39696. eyeToScreenDistance: number;
  39697. /**
  39698. * Define the distance between both lenses
  39699. */
  39700. lensSeparationDistance: number;
  39701. /**
  39702. * Define the distance between both viewer's eyes.
  39703. */
  39704. interpupillaryDistance: number;
  39705. /**
  39706. * Define the distortion factor of the VR postprocess.
  39707. * Please, touch with care.
  39708. */
  39709. distortionK: number[];
  39710. /**
  39711. * Define the chromatic aberration correction factors for the VR post process.
  39712. */
  39713. chromaAbCorrection: number[];
  39714. /**
  39715. * Define the scale factor of the post process.
  39716. * The smaller the better but the slower.
  39717. */
  39718. postProcessScaleFactor: number;
  39719. /**
  39720. * Define an offset for the lens center.
  39721. */
  39722. lensCenterOffset: number;
  39723. /**
  39724. * Define if the current vr camera should compensate the distortion of the lense or not.
  39725. */
  39726. compensateDistortion: boolean;
  39727. /**
  39728. * Defines if multiview should be enabled when rendering (Default: false)
  39729. */
  39730. multiviewEnabled: boolean;
  39731. /**
  39732. * Gets the rendering aspect ratio based on the provided resolutions.
  39733. */
  39734. readonly aspectRatio: number;
  39735. /**
  39736. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39737. */
  39738. readonly aspectRatioFov: number;
  39739. /**
  39740. * @hidden
  39741. */
  39742. readonly leftHMatrix: Matrix;
  39743. /**
  39744. * @hidden
  39745. */
  39746. readonly rightHMatrix: Matrix;
  39747. /**
  39748. * @hidden
  39749. */
  39750. readonly leftPreViewMatrix: Matrix;
  39751. /**
  39752. * @hidden
  39753. */
  39754. readonly rightPreViewMatrix: Matrix;
  39755. /**
  39756. * Get the default VRMetrics based on the most generic setup.
  39757. * @returns the default vr metrics
  39758. */
  39759. static GetDefault(): VRCameraMetrics;
  39760. }
  39761. }
  39762. declare module BABYLON {
  39763. /** @hidden */
  39764. export var vrDistortionCorrectionPixelShader: {
  39765. name: string;
  39766. shader: string;
  39767. };
  39768. }
  39769. declare module BABYLON {
  39770. /**
  39771. * VRDistortionCorrectionPostProcess used for mobile VR
  39772. */
  39773. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39774. private _isRightEye;
  39775. private _distortionFactors;
  39776. private _postProcessScaleFactor;
  39777. private _lensCenterOffset;
  39778. private _scaleIn;
  39779. private _scaleFactor;
  39780. private _lensCenter;
  39781. /**
  39782. * Initializes the VRDistortionCorrectionPostProcess
  39783. * @param name The name of the effect.
  39784. * @param camera The camera to apply the render pass to.
  39785. * @param isRightEye If this is for the right eye distortion
  39786. * @param vrMetrics All the required metrics for the VR camera
  39787. */
  39788. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39789. }
  39790. }
  39791. declare module BABYLON {
  39792. /**
  39793. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39794. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39795. */
  39796. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39797. /**
  39798. * Creates a new VRDeviceOrientationArcRotateCamera
  39799. * @param name defines camera name
  39800. * @param alpha defines the camera rotation along the logitudinal axis
  39801. * @param beta defines the camera rotation along the latitudinal axis
  39802. * @param radius defines the camera distance from its target
  39803. * @param target defines the camera target
  39804. * @param scene defines the scene the camera belongs to
  39805. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39806. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39807. */
  39808. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39809. /**
  39810. * Gets camera class name
  39811. * @returns VRDeviceOrientationArcRotateCamera
  39812. */
  39813. getClassName(): string;
  39814. }
  39815. }
  39816. declare module BABYLON {
  39817. /**
  39818. * Camera used to simulate VR rendering (based on FreeCamera)
  39819. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39820. */
  39821. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39822. /**
  39823. * Creates a new VRDeviceOrientationFreeCamera
  39824. * @param name defines camera name
  39825. * @param position defines the start position of the camera
  39826. * @param scene defines the scene the camera belongs to
  39827. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39828. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39829. */
  39830. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39831. /**
  39832. * Gets camera class name
  39833. * @returns VRDeviceOrientationFreeCamera
  39834. */
  39835. getClassName(): string;
  39836. }
  39837. }
  39838. declare module BABYLON {
  39839. /**
  39840. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39841. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39842. */
  39843. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39844. /**
  39845. * Creates a new VRDeviceOrientationGamepadCamera
  39846. * @param name defines camera name
  39847. * @param position defines the start position of the camera
  39848. * @param scene defines the scene the camera belongs to
  39849. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39850. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39851. */
  39852. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39853. /**
  39854. * Gets camera class name
  39855. * @returns VRDeviceOrientationGamepadCamera
  39856. */
  39857. getClassName(): string;
  39858. }
  39859. }
  39860. declare module BABYLON {
  39861. /**
  39862. * Base class of materials working in push mode in babylon JS
  39863. * @hidden
  39864. */
  39865. export class PushMaterial extends Material {
  39866. protected _activeEffect: Effect;
  39867. protected _normalMatrix: Matrix;
  39868. /**
  39869. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39870. * This means that the material can keep using a previous shader while a new one is being compiled.
  39871. * This is mostly used when shader parallel compilation is supported (true by default)
  39872. */
  39873. allowShaderHotSwapping: boolean;
  39874. constructor(name: string, scene: Scene);
  39875. getEffect(): Effect;
  39876. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39877. /**
  39878. * Binds the given world matrix to the active effect
  39879. *
  39880. * @param world the matrix to bind
  39881. */
  39882. bindOnlyWorldMatrix(world: Matrix): void;
  39883. /**
  39884. * Binds the given normal matrix to the active effect
  39885. *
  39886. * @param normalMatrix the matrix to bind
  39887. */
  39888. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39889. bind(world: Matrix, mesh?: Mesh): void;
  39890. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39891. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39892. }
  39893. }
  39894. declare module BABYLON {
  39895. /**
  39896. * This groups all the flags used to control the materials channel.
  39897. */
  39898. export class MaterialFlags {
  39899. private static _DiffuseTextureEnabled;
  39900. /**
  39901. * Are diffuse textures enabled in the application.
  39902. */
  39903. static DiffuseTextureEnabled: boolean;
  39904. private static _AmbientTextureEnabled;
  39905. /**
  39906. * Are ambient textures enabled in the application.
  39907. */
  39908. static AmbientTextureEnabled: boolean;
  39909. private static _OpacityTextureEnabled;
  39910. /**
  39911. * Are opacity textures enabled in the application.
  39912. */
  39913. static OpacityTextureEnabled: boolean;
  39914. private static _ReflectionTextureEnabled;
  39915. /**
  39916. * Are reflection textures enabled in the application.
  39917. */
  39918. static ReflectionTextureEnabled: boolean;
  39919. private static _EmissiveTextureEnabled;
  39920. /**
  39921. * Are emissive textures enabled in the application.
  39922. */
  39923. static EmissiveTextureEnabled: boolean;
  39924. private static _SpecularTextureEnabled;
  39925. /**
  39926. * Are specular textures enabled in the application.
  39927. */
  39928. static SpecularTextureEnabled: boolean;
  39929. private static _BumpTextureEnabled;
  39930. /**
  39931. * Are bump textures enabled in the application.
  39932. */
  39933. static BumpTextureEnabled: boolean;
  39934. private static _LightmapTextureEnabled;
  39935. /**
  39936. * Are lightmap textures enabled in the application.
  39937. */
  39938. static LightmapTextureEnabled: boolean;
  39939. private static _RefractionTextureEnabled;
  39940. /**
  39941. * Are refraction textures enabled in the application.
  39942. */
  39943. static RefractionTextureEnabled: boolean;
  39944. private static _ColorGradingTextureEnabled;
  39945. /**
  39946. * Are color grading textures enabled in the application.
  39947. */
  39948. static ColorGradingTextureEnabled: boolean;
  39949. private static _FresnelEnabled;
  39950. /**
  39951. * Are fresnels enabled in the application.
  39952. */
  39953. static FresnelEnabled: boolean;
  39954. private static _ClearCoatTextureEnabled;
  39955. /**
  39956. * Are clear coat textures enabled in the application.
  39957. */
  39958. static ClearCoatTextureEnabled: boolean;
  39959. private static _ClearCoatBumpTextureEnabled;
  39960. /**
  39961. * Are clear coat bump textures enabled in the application.
  39962. */
  39963. static ClearCoatBumpTextureEnabled: boolean;
  39964. private static _ClearCoatTintTextureEnabled;
  39965. /**
  39966. * Are clear coat tint textures enabled in the application.
  39967. */
  39968. static ClearCoatTintTextureEnabled: boolean;
  39969. private static _SheenTextureEnabled;
  39970. /**
  39971. * Are sheen textures enabled in the application.
  39972. */
  39973. static SheenTextureEnabled: boolean;
  39974. private static _AnisotropicTextureEnabled;
  39975. /**
  39976. * Are anisotropic textures enabled in the application.
  39977. */
  39978. static AnisotropicTextureEnabled: boolean;
  39979. private static _ThicknessTextureEnabled;
  39980. /**
  39981. * Are thickness textures enabled in the application.
  39982. */
  39983. static ThicknessTextureEnabled: boolean;
  39984. }
  39985. }
  39986. declare module BABYLON {
  39987. /** @hidden */
  39988. export var defaultFragmentDeclaration: {
  39989. name: string;
  39990. shader: string;
  39991. };
  39992. }
  39993. declare module BABYLON {
  39994. /** @hidden */
  39995. export var defaultUboDeclaration: {
  39996. name: string;
  39997. shader: string;
  39998. };
  39999. }
  40000. declare module BABYLON {
  40001. /** @hidden */
  40002. export var lightFragmentDeclaration: {
  40003. name: string;
  40004. shader: string;
  40005. };
  40006. }
  40007. declare module BABYLON {
  40008. /** @hidden */
  40009. export var lightUboDeclaration: {
  40010. name: string;
  40011. shader: string;
  40012. };
  40013. }
  40014. declare module BABYLON {
  40015. /** @hidden */
  40016. export var lightsFragmentFunctions: {
  40017. name: string;
  40018. shader: string;
  40019. };
  40020. }
  40021. declare module BABYLON {
  40022. /** @hidden */
  40023. export var shadowsFragmentFunctions: {
  40024. name: string;
  40025. shader: string;
  40026. };
  40027. }
  40028. declare module BABYLON {
  40029. /** @hidden */
  40030. export var fresnelFunction: {
  40031. name: string;
  40032. shader: string;
  40033. };
  40034. }
  40035. declare module BABYLON {
  40036. /** @hidden */
  40037. export var reflectionFunction: {
  40038. name: string;
  40039. shader: string;
  40040. };
  40041. }
  40042. declare module BABYLON {
  40043. /** @hidden */
  40044. export var bumpFragmentFunctions: {
  40045. name: string;
  40046. shader: string;
  40047. };
  40048. }
  40049. declare module BABYLON {
  40050. /** @hidden */
  40051. export var logDepthDeclaration: {
  40052. name: string;
  40053. shader: string;
  40054. };
  40055. }
  40056. declare module BABYLON {
  40057. /** @hidden */
  40058. export var bumpFragment: {
  40059. name: string;
  40060. shader: string;
  40061. };
  40062. }
  40063. declare module BABYLON {
  40064. /** @hidden */
  40065. export var depthPrePass: {
  40066. name: string;
  40067. shader: string;
  40068. };
  40069. }
  40070. declare module BABYLON {
  40071. /** @hidden */
  40072. export var lightFragment: {
  40073. name: string;
  40074. shader: string;
  40075. };
  40076. }
  40077. declare module BABYLON {
  40078. /** @hidden */
  40079. export var logDepthFragment: {
  40080. name: string;
  40081. shader: string;
  40082. };
  40083. }
  40084. declare module BABYLON {
  40085. /** @hidden */
  40086. export var defaultPixelShader: {
  40087. name: string;
  40088. shader: string;
  40089. };
  40090. }
  40091. declare module BABYLON {
  40092. /** @hidden */
  40093. export var defaultVertexDeclaration: {
  40094. name: string;
  40095. shader: string;
  40096. };
  40097. }
  40098. declare module BABYLON {
  40099. /** @hidden */
  40100. export var bumpVertexDeclaration: {
  40101. name: string;
  40102. shader: string;
  40103. };
  40104. }
  40105. declare module BABYLON {
  40106. /** @hidden */
  40107. export var bumpVertex: {
  40108. name: string;
  40109. shader: string;
  40110. };
  40111. }
  40112. declare module BABYLON {
  40113. /** @hidden */
  40114. export var fogVertex: {
  40115. name: string;
  40116. shader: string;
  40117. };
  40118. }
  40119. declare module BABYLON {
  40120. /** @hidden */
  40121. export var shadowsVertex: {
  40122. name: string;
  40123. shader: string;
  40124. };
  40125. }
  40126. declare module BABYLON {
  40127. /** @hidden */
  40128. export var pointCloudVertex: {
  40129. name: string;
  40130. shader: string;
  40131. };
  40132. }
  40133. declare module BABYLON {
  40134. /** @hidden */
  40135. export var logDepthVertex: {
  40136. name: string;
  40137. shader: string;
  40138. };
  40139. }
  40140. declare module BABYLON {
  40141. /** @hidden */
  40142. export var defaultVertexShader: {
  40143. name: string;
  40144. shader: string;
  40145. };
  40146. }
  40147. declare module BABYLON {
  40148. /** @hidden */
  40149. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40150. MAINUV1: boolean;
  40151. MAINUV2: boolean;
  40152. DIFFUSE: boolean;
  40153. DIFFUSEDIRECTUV: number;
  40154. AMBIENT: boolean;
  40155. AMBIENTDIRECTUV: number;
  40156. OPACITY: boolean;
  40157. OPACITYDIRECTUV: number;
  40158. OPACITYRGB: boolean;
  40159. REFLECTION: boolean;
  40160. EMISSIVE: boolean;
  40161. EMISSIVEDIRECTUV: number;
  40162. SPECULAR: boolean;
  40163. SPECULARDIRECTUV: number;
  40164. BUMP: boolean;
  40165. BUMPDIRECTUV: number;
  40166. PARALLAX: boolean;
  40167. PARALLAXOCCLUSION: boolean;
  40168. SPECULAROVERALPHA: boolean;
  40169. CLIPPLANE: boolean;
  40170. CLIPPLANE2: boolean;
  40171. CLIPPLANE3: boolean;
  40172. CLIPPLANE4: boolean;
  40173. ALPHATEST: boolean;
  40174. DEPTHPREPASS: boolean;
  40175. ALPHAFROMDIFFUSE: boolean;
  40176. POINTSIZE: boolean;
  40177. FOG: boolean;
  40178. SPECULARTERM: boolean;
  40179. DIFFUSEFRESNEL: boolean;
  40180. OPACITYFRESNEL: boolean;
  40181. REFLECTIONFRESNEL: boolean;
  40182. REFRACTIONFRESNEL: boolean;
  40183. EMISSIVEFRESNEL: boolean;
  40184. FRESNEL: boolean;
  40185. NORMAL: boolean;
  40186. UV1: boolean;
  40187. UV2: boolean;
  40188. VERTEXCOLOR: boolean;
  40189. VERTEXALPHA: boolean;
  40190. NUM_BONE_INFLUENCERS: number;
  40191. BonesPerMesh: number;
  40192. BONETEXTURE: boolean;
  40193. INSTANCES: boolean;
  40194. GLOSSINESS: boolean;
  40195. ROUGHNESS: boolean;
  40196. EMISSIVEASILLUMINATION: boolean;
  40197. LINKEMISSIVEWITHDIFFUSE: boolean;
  40198. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40199. LIGHTMAP: boolean;
  40200. LIGHTMAPDIRECTUV: number;
  40201. OBJECTSPACE_NORMALMAP: boolean;
  40202. USELIGHTMAPASSHADOWMAP: boolean;
  40203. REFLECTIONMAP_3D: boolean;
  40204. REFLECTIONMAP_SPHERICAL: boolean;
  40205. REFLECTIONMAP_PLANAR: boolean;
  40206. REFLECTIONMAP_CUBIC: boolean;
  40207. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40208. REFLECTIONMAP_PROJECTION: boolean;
  40209. REFLECTIONMAP_SKYBOX: boolean;
  40210. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40211. REFLECTIONMAP_EXPLICIT: boolean;
  40212. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40213. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40214. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40215. INVERTCUBICMAP: boolean;
  40216. LOGARITHMICDEPTH: boolean;
  40217. REFRACTION: boolean;
  40218. REFRACTIONMAP_3D: boolean;
  40219. REFLECTIONOVERALPHA: boolean;
  40220. TWOSIDEDLIGHTING: boolean;
  40221. SHADOWFLOAT: boolean;
  40222. MORPHTARGETS: boolean;
  40223. MORPHTARGETS_NORMAL: boolean;
  40224. MORPHTARGETS_TANGENT: boolean;
  40225. MORPHTARGETS_UV: boolean;
  40226. NUM_MORPH_INFLUENCERS: number;
  40227. NONUNIFORMSCALING: boolean;
  40228. PREMULTIPLYALPHA: boolean;
  40229. IMAGEPROCESSING: boolean;
  40230. VIGNETTE: boolean;
  40231. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40232. VIGNETTEBLENDMODEOPAQUE: boolean;
  40233. TONEMAPPING: boolean;
  40234. TONEMAPPING_ACES: boolean;
  40235. CONTRAST: boolean;
  40236. COLORCURVES: boolean;
  40237. COLORGRADING: boolean;
  40238. COLORGRADING3D: boolean;
  40239. SAMPLER3DGREENDEPTH: boolean;
  40240. SAMPLER3DBGRMAP: boolean;
  40241. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40242. MULTIVIEW: boolean;
  40243. /**
  40244. * If the reflection texture on this material is in linear color space
  40245. * @hidden
  40246. */
  40247. IS_REFLECTION_LINEAR: boolean;
  40248. /**
  40249. * If the refraction texture on this material is in linear color space
  40250. * @hidden
  40251. */
  40252. IS_REFRACTION_LINEAR: boolean;
  40253. EXPOSURE: boolean;
  40254. constructor();
  40255. setReflectionMode(modeToEnable: string): void;
  40256. }
  40257. /**
  40258. * This is the default material used in Babylon. It is the best trade off between quality
  40259. * and performances.
  40260. * @see http://doc.babylonjs.com/babylon101/materials
  40261. */
  40262. export class StandardMaterial extends PushMaterial {
  40263. private _diffuseTexture;
  40264. /**
  40265. * The basic texture of the material as viewed under a light.
  40266. */
  40267. diffuseTexture: Nullable<BaseTexture>;
  40268. private _ambientTexture;
  40269. /**
  40270. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40271. */
  40272. ambientTexture: Nullable<BaseTexture>;
  40273. private _opacityTexture;
  40274. /**
  40275. * Define the transparency of the material from a texture.
  40276. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40277. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40278. */
  40279. opacityTexture: Nullable<BaseTexture>;
  40280. private _reflectionTexture;
  40281. /**
  40282. * Define the texture used to display the reflection.
  40283. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40284. */
  40285. reflectionTexture: Nullable<BaseTexture>;
  40286. private _emissiveTexture;
  40287. /**
  40288. * Define texture of the material as if self lit.
  40289. * This will be mixed in the final result even in the absence of light.
  40290. */
  40291. emissiveTexture: Nullable<BaseTexture>;
  40292. private _specularTexture;
  40293. /**
  40294. * Define how the color and intensity of the highlight given by the light in the material.
  40295. */
  40296. specularTexture: Nullable<BaseTexture>;
  40297. private _bumpTexture;
  40298. /**
  40299. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40300. * 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.
  40301. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40302. */
  40303. bumpTexture: Nullable<BaseTexture>;
  40304. private _lightmapTexture;
  40305. /**
  40306. * Complex lighting can be computationally expensive to compute at runtime.
  40307. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40308. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40309. */
  40310. lightmapTexture: Nullable<BaseTexture>;
  40311. private _refractionTexture;
  40312. /**
  40313. * Define the texture used to display the refraction.
  40314. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40315. */
  40316. refractionTexture: Nullable<BaseTexture>;
  40317. /**
  40318. * The color of the material lit by the environmental background lighting.
  40319. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40320. */
  40321. ambientColor: Color3;
  40322. /**
  40323. * The basic color of the material as viewed under a light.
  40324. */
  40325. diffuseColor: Color3;
  40326. /**
  40327. * Define how the color and intensity of the highlight given by the light in the material.
  40328. */
  40329. specularColor: Color3;
  40330. /**
  40331. * Define the color of the material as if self lit.
  40332. * This will be mixed in the final result even in the absence of light.
  40333. */
  40334. emissiveColor: Color3;
  40335. /**
  40336. * Defines how sharp are the highlights in the material.
  40337. * The bigger the value the sharper giving a more glossy feeling to the result.
  40338. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40339. */
  40340. specularPower: number;
  40341. private _useAlphaFromDiffuseTexture;
  40342. /**
  40343. * Does the transparency come from the diffuse texture alpha channel.
  40344. */
  40345. useAlphaFromDiffuseTexture: boolean;
  40346. private _useEmissiveAsIllumination;
  40347. /**
  40348. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40349. */
  40350. useEmissiveAsIllumination: boolean;
  40351. private _linkEmissiveWithDiffuse;
  40352. /**
  40353. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40354. * the emissive level when the final color is close to one.
  40355. */
  40356. linkEmissiveWithDiffuse: boolean;
  40357. private _useSpecularOverAlpha;
  40358. /**
  40359. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40360. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40361. */
  40362. useSpecularOverAlpha: boolean;
  40363. private _useReflectionOverAlpha;
  40364. /**
  40365. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40366. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40367. */
  40368. useReflectionOverAlpha: boolean;
  40369. private _disableLighting;
  40370. /**
  40371. * Does lights from the scene impacts this material.
  40372. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40373. */
  40374. disableLighting: boolean;
  40375. private _useObjectSpaceNormalMap;
  40376. /**
  40377. * Allows using an object space normal map (instead of tangent space).
  40378. */
  40379. useObjectSpaceNormalMap: boolean;
  40380. private _useParallax;
  40381. /**
  40382. * Is parallax enabled or not.
  40383. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40384. */
  40385. useParallax: boolean;
  40386. private _useParallaxOcclusion;
  40387. /**
  40388. * Is parallax occlusion enabled or not.
  40389. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40390. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40391. */
  40392. useParallaxOcclusion: boolean;
  40393. /**
  40394. * 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.
  40395. */
  40396. parallaxScaleBias: number;
  40397. private _roughness;
  40398. /**
  40399. * Helps to define how blurry the reflections should appears in the material.
  40400. */
  40401. roughness: number;
  40402. /**
  40403. * In case of refraction, define the value of the index of refraction.
  40404. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40405. */
  40406. indexOfRefraction: number;
  40407. /**
  40408. * Invert the refraction texture alongside the y axis.
  40409. * It can be useful with procedural textures or probe for instance.
  40410. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40411. */
  40412. invertRefractionY: boolean;
  40413. /**
  40414. * Defines the alpha limits in alpha test mode.
  40415. */
  40416. alphaCutOff: number;
  40417. private _useLightmapAsShadowmap;
  40418. /**
  40419. * In case of light mapping, define whether the map contains light or shadow informations.
  40420. */
  40421. useLightmapAsShadowmap: boolean;
  40422. private _diffuseFresnelParameters;
  40423. /**
  40424. * Define the diffuse fresnel parameters of the material.
  40425. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40426. */
  40427. diffuseFresnelParameters: FresnelParameters;
  40428. private _opacityFresnelParameters;
  40429. /**
  40430. * Define the opacity fresnel parameters of the material.
  40431. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40432. */
  40433. opacityFresnelParameters: FresnelParameters;
  40434. private _reflectionFresnelParameters;
  40435. /**
  40436. * Define the reflection fresnel parameters of the material.
  40437. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40438. */
  40439. reflectionFresnelParameters: FresnelParameters;
  40440. private _refractionFresnelParameters;
  40441. /**
  40442. * Define the refraction fresnel parameters of the material.
  40443. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40444. */
  40445. refractionFresnelParameters: FresnelParameters;
  40446. private _emissiveFresnelParameters;
  40447. /**
  40448. * Define the emissive fresnel parameters of the material.
  40449. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40450. */
  40451. emissiveFresnelParameters: FresnelParameters;
  40452. private _useReflectionFresnelFromSpecular;
  40453. /**
  40454. * If true automatically deducts the fresnels values from the material specularity.
  40455. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40456. */
  40457. useReflectionFresnelFromSpecular: boolean;
  40458. private _useGlossinessFromSpecularMapAlpha;
  40459. /**
  40460. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40461. */
  40462. useGlossinessFromSpecularMapAlpha: boolean;
  40463. private _maxSimultaneousLights;
  40464. /**
  40465. * Defines the maximum number of lights that can be used in the material
  40466. */
  40467. maxSimultaneousLights: number;
  40468. private _invertNormalMapX;
  40469. /**
  40470. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40471. */
  40472. invertNormalMapX: boolean;
  40473. private _invertNormalMapY;
  40474. /**
  40475. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40476. */
  40477. invertNormalMapY: boolean;
  40478. private _twoSidedLighting;
  40479. /**
  40480. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40481. */
  40482. twoSidedLighting: boolean;
  40483. /**
  40484. * Default configuration related to image processing available in the standard Material.
  40485. */
  40486. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40487. /**
  40488. * Gets the image processing configuration used either in this material.
  40489. */
  40490. /**
  40491. * Sets the Default image processing configuration used either in the this material.
  40492. *
  40493. * If sets to null, the scene one is in use.
  40494. */
  40495. imageProcessingConfiguration: ImageProcessingConfiguration;
  40496. /**
  40497. * Keep track of the image processing observer to allow dispose and replace.
  40498. */
  40499. private _imageProcessingObserver;
  40500. /**
  40501. * Attaches a new image processing configuration to the Standard Material.
  40502. * @param configuration
  40503. */
  40504. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40505. /**
  40506. * Gets wether the color curves effect is enabled.
  40507. */
  40508. /**
  40509. * Sets wether the color curves effect is enabled.
  40510. */
  40511. cameraColorCurvesEnabled: boolean;
  40512. /**
  40513. * Gets wether the color grading effect is enabled.
  40514. */
  40515. /**
  40516. * Gets wether the color grading effect is enabled.
  40517. */
  40518. cameraColorGradingEnabled: boolean;
  40519. /**
  40520. * Gets wether tonemapping is enabled or not.
  40521. */
  40522. /**
  40523. * Sets wether tonemapping is enabled or not
  40524. */
  40525. cameraToneMappingEnabled: boolean;
  40526. /**
  40527. * The camera exposure used on this material.
  40528. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40529. * This corresponds to a photographic exposure.
  40530. */
  40531. /**
  40532. * The camera exposure used on this material.
  40533. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40534. * This corresponds to a photographic exposure.
  40535. */
  40536. cameraExposure: number;
  40537. /**
  40538. * Gets The camera contrast used on this material.
  40539. */
  40540. /**
  40541. * Sets The camera contrast used on this material.
  40542. */
  40543. cameraContrast: number;
  40544. /**
  40545. * Gets the Color Grading 2D Lookup Texture.
  40546. */
  40547. /**
  40548. * Sets the Color Grading 2D Lookup Texture.
  40549. */
  40550. cameraColorGradingTexture: Nullable<BaseTexture>;
  40551. /**
  40552. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40553. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40554. * 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;
  40555. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40556. */
  40557. /**
  40558. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40559. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40560. * 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;
  40561. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40562. */
  40563. cameraColorCurves: Nullable<ColorCurves>;
  40564. /**
  40565. * Custom callback helping to override the default shader used in the material.
  40566. */
  40567. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40568. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40569. protected _worldViewProjectionMatrix: Matrix;
  40570. protected _globalAmbientColor: Color3;
  40571. protected _useLogarithmicDepth: boolean;
  40572. protected _rebuildInParallel: boolean;
  40573. /**
  40574. * Instantiates a new standard material.
  40575. * This is the default material used in Babylon. It is the best trade off between quality
  40576. * and performances.
  40577. * @see http://doc.babylonjs.com/babylon101/materials
  40578. * @param name Define the name of the material in the scene
  40579. * @param scene Define the scene the material belong to
  40580. */
  40581. constructor(name: string, scene: Scene);
  40582. /**
  40583. * Gets a boolean indicating that current material needs to register RTT
  40584. */
  40585. readonly hasRenderTargetTextures: boolean;
  40586. /**
  40587. * Gets the current class name of the material e.g. "StandardMaterial"
  40588. * Mainly use in serialization.
  40589. * @returns the class name
  40590. */
  40591. getClassName(): string;
  40592. /**
  40593. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40594. * You can try switching to logarithmic depth.
  40595. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40596. */
  40597. useLogarithmicDepth: boolean;
  40598. /**
  40599. * Specifies if the material will require alpha blending
  40600. * @returns a boolean specifying if alpha blending is needed
  40601. */
  40602. needAlphaBlending(): boolean;
  40603. /**
  40604. * Specifies if this material should be rendered in alpha test mode
  40605. * @returns a boolean specifying if an alpha test is needed.
  40606. */
  40607. needAlphaTesting(): boolean;
  40608. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40609. /**
  40610. * Get the texture used for alpha test purpose.
  40611. * @returns the diffuse texture in case of the standard material.
  40612. */
  40613. getAlphaTestTexture(): Nullable<BaseTexture>;
  40614. /**
  40615. * Get if the submesh is ready to be used and all its information available.
  40616. * Child classes can use it to update shaders
  40617. * @param mesh defines the mesh to check
  40618. * @param subMesh defines which submesh to check
  40619. * @param useInstances specifies that instances should be used
  40620. * @returns a boolean indicating that the submesh is ready or not
  40621. */
  40622. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40623. /**
  40624. * Builds the material UBO layouts.
  40625. * Used internally during the effect preparation.
  40626. */
  40627. buildUniformLayout(): void;
  40628. /**
  40629. * Unbinds the material from the mesh
  40630. */
  40631. unbind(): void;
  40632. /**
  40633. * Binds the submesh to this material by preparing the effect and shader to draw
  40634. * @param world defines the world transformation matrix
  40635. * @param mesh defines the mesh containing the submesh
  40636. * @param subMesh defines the submesh to bind the material to
  40637. */
  40638. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40639. /**
  40640. * Get the list of animatables in the material.
  40641. * @returns the list of animatables object used in the material
  40642. */
  40643. getAnimatables(): IAnimatable[];
  40644. /**
  40645. * Gets the active textures from the material
  40646. * @returns an array of textures
  40647. */
  40648. getActiveTextures(): BaseTexture[];
  40649. /**
  40650. * Specifies if the material uses a texture
  40651. * @param texture defines the texture to check against the material
  40652. * @returns a boolean specifying if the material uses the texture
  40653. */
  40654. hasTexture(texture: BaseTexture): boolean;
  40655. /**
  40656. * Disposes the material
  40657. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40658. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40659. */
  40660. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40661. /**
  40662. * Makes a duplicate of the material, and gives it a new name
  40663. * @param name defines the new name for the duplicated material
  40664. * @returns the cloned material
  40665. */
  40666. clone(name: string): StandardMaterial;
  40667. /**
  40668. * Serializes this material in a JSON representation
  40669. * @returns the serialized material object
  40670. */
  40671. serialize(): any;
  40672. /**
  40673. * Creates a standard material from parsed material data
  40674. * @param source defines the JSON representation of the material
  40675. * @param scene defines the hosting scene
  40676. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40677. * @returns a new standard material
  40678. */
  40679. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40680. /**
  40681. * Are diffuse textures enabled in the application.
  40682. */
  40683. static DiffuseTextureEnabled: boolean;
  40684. /**
  40685. * Are ambient textures enabled in the application.
  40686. */
  40687. static AmbientTextureEnabled: boolean;
  40688. /**
  40689. * Are opacity textures enabled in the application.
  40690. */
  40691. static OpacityTextureEnabled: boolean;
  40692. /**
  40693. * Are reflection textures enabled in the application.
  40694. */
  40695. static ReflectionTextureEnabled: boolean;
  40696. /**
  40697. * Are emissive textures enabled in the application.
  40698. */
  40699. static EmissiveTextureEnabled: boolean;
  40700. /**
  40701. * Are specular textures enabled in the application.
  40702. */
  40703. static SpecularTextureEnabled: boolean;
  40704. /**
  40705. * Are bump textures enabled in the application.
  40706. */
  40707. static BumpTextureEnabled: boolean;
  40708. /**
  40709. * Are lightmap textures enabled in the application.
  40710. */
  40711. static LightmapTextureEnabled: boolean;
  40712. /**
  40713. * Are refraction textures enabled in the application.
  40714. */
  40715. static RefractionTextureEnabled: boolean;
  40716. /**
  40717. * Are color grading textures enabled in the application.
  40718. */
  40719. static ColorGradingTextureEnabled: boolean;
  40720. /**
  40721. * Are fresnels enabled in the application.
  40722. */
  40723. static FresnelEnabled: boolean;
  40724. }
  40725. }
  40726. declare module BABYLON {
  40727. /** @hidden */
  40728. export var imageProcessingPixelShader: {
  40729. name: string;
  40730. shader: string;
  40731. };
  40732. }
  40733. declare module BABYLON {
  40734. /**
  40735. * ImageProcessingPostProcess
  40736. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40737. */
  40738. export class ImageProcessingPostProcess extends PostProcess {
  40739. /**
  40740. * Default configuration related to image processing available in the PBR Material.
  40741. */
  40742. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40743. /**
  40744. * Gets the image processing configuration used either in this material.
  40745. */
  40746. /**
  40747. * Sets the Default image processing configuration used either in the this material.
  40748. *
  40749. * If sets to null, the scene one is in use.
  40750. */
  40751. imageProcessingConfiguration: ImageProcessingConfiguration;
  40752. /**
  40753. * Keep track of the image processing observer to allow dispose and replace.
  40754. */
  40755. private _imageProcessingObserver;
  40756. /**
  40757. * Attaches a new image processing configuration to the PBR Material.
  40758. * @param configuration
  40759. */
  40760. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40761. /**
  40762. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40763. */
  40764. /**
  40765. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40766. */
  40767. colorCurves: Nullable<ColorCurves>;
  40768. /**
  40769. * Gets wether the color curves effect is enabled.
  40770. */
  40771. /**
  40772. * Sets wether the color curves effect is enabled.
  40773. */
  40774. colorCurvesEnabled: boolean;
  40775. /**
  40776. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40777. */
  40778. /**
  40779. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40780. */
  40781. colorGradingTexture: Nullable<BaseTexture>;
  40782. /**
  40783. * Gets wether the color grading effect is enabled.
  40784. */
  40785. /**
  40786. * Gets wether the color grading effect is enabled.
  40787. */
  40788. colorGradingEnabled: boolean;
  40789. /**
  40790. * Gets exposure used in the effect.
  40791. */
  40792. /**
  40793. * Sets exposure used in the effect.
  40794. */
  40795. exposure: number;
  40796. /**
  40797. * Gets wether tonemapping is enabled or not.
  40798. */
  40799. /**
  40800. * Sets wether tonemapping is enabled or not
  40801. */
  40802. toneMappingEnabled: boolean;
  40803. /**
  40804. * Gets the type of tone mapping effect.
  40805. */
  40806. /**
  40807. * Sets the type of tone mapping effect.
  40808. */
  40809. toneMappingType: number;
  40810. /**
  40811. * Gets contrast used in the effect.
  40812. */
  40813. /**
  40814. * Sets contrast used in the effect.
  40815. */
  40816. contrast: number;
  40817. /**
  40818. * Gets Vignette stretch size.
  40819. */
  40820. /**
  40821. * Sets Vignette stretch size.
  40822. */
  40823. vignetteStretch: number;
  40824. /**
  40825. * Gets Vignette centre X Offset.
  40826. */
  40827. /**
  40828. * Sets Vignette centre X Offset.
  40829. */
  40830. vignetteCentreX: number;
  40831. /**
  40832. * Gets Vignette centre Y Offset.
  40833. */
  40834. /**
  40835. * Sets Vignette centre Y Offset.
  40836. */
  40837. vignetteCentreY: number;
  40838. /**
  40839. * Gets Vignette weight or intensity of the vignette effect.
  40840. */
  40841. /**
  40842. * Sets Vignette weight or intensity of the vignette effect.
  40843. */
  40844. vignetteWeight: number;
  40845. /**
  40846. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40847. * if vignetteEnabled is set to true.
  40848. */
  40849. /**
  40850. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40851. * if vignetteEnabled is set to true.
  40852. */
  40853. vignetteColor: Color4;
  40854. /**
  40855. * Gets Camera field of view used by the Vignette effect.
  40856. */
  40857. /**
  40858. * Sets Camera field of view used by the Vignette effect.
  40859. */
  40860. vignetteCameraFov: number;
  40861. /**
  40862. * Gets the vignette blend mode allowing different kind of effect.
  40863. */
  40864. /**
  40865. * Sets the vignette blend mode allowing different kind of effect.
  40866. */
  40867. vignetteBlendMode: number;
  40868. /**
  40869. * Gets wether the vignette effect is enabled.
  40870. */
  40871. /**
  40872. * Sets wether the vignette effect is enabled.
  40873. */
  40874. vignetteEnabled: boolean;
  40875. private _fromLinearSpace;
  40876. /**
  40877. * Gets wether the input of the processing is in Gamma or Linear Space.
  40878. */
  40879. /**
  40880. * Sets wether the input of the processing is in Gamma or Linear Space.
  40881. */
  40882. fromLinearSpace: boolean;
  40883. /**
  40884. * Defines cache preventing GC.
  40885. */
  40886. private _defines;
  40887. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40888. /**
  40889. * "ImageProcessingPostProcess"
  40890. * @returns "ImageProcessingPostProcess"
  40891. */
  40892. getClassName(): string;
  40893. protected _updateParameters(): void;
  40894. dispose(camera?: Camera): void;
  40895. }
  40896. }
  40897. declare module BABYLON {
  40898. /**
  40899. * Class containing static functions to help procedurally build meshes
  40900. */
  40901. export class GroundBuilder {
  40902. /**
  40903. * Creates a ground mesh
  40904. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40905. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40907. * @param name defines the name of the mesh
  40908. * @param options defines the options used to create the mesh
  40909. * @param scene defines the hosting scene
  40910. * @returns the ground mesh
  40911. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40912. */
  40913. static CreateGround(name: string, options: {
  40914. width?: number;
  40915. height?: number;
  40916. subdivisions?: number;
  40917. subdivisionsX?: number;
  40918. subdivisionsY?: number;
  40919. updatable?: boolean;
  40920. }, scene: any): Mesh;
  40921. /**
  40922. * Creates a tiled ground mesh
  40923. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40924. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40925. * * 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
  40926. * * 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
  40927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40928. * @param name defines the name of the mesh
  40929. * @param options defines the options used to create the mesh
  40930. * @param scene defines the hosting scene
  40931. * @returns the tiled ground mesh
  40932. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40933. */
  40934. static CreateTiledGround(name: string, options: {
  40935. xmin: number;
  40936. zmin: number;
  40937. xmax: number;
  40938. zmax: number;
  40939. subdivisions?: {
  40940. w: number;
  40941. h: number;
  40942. };
  40943. precision?: {
  40944. w: number;
  40945. h: number;
  40946. };
  40947. updatable?: boolean;
  40948. }, scene?: Nullable<Scene>): Mesh;
  40949. /**
  40950. * Creates a ground mesh from a height map
  40951. * * The parameter `url` sets the URL of the height map image resource.
  40952. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40953. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40954. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40955. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40956. * * 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.
  40957. * * 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).
  40958. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40960. * @param name defines the name of the mesh
  40961. * @param url defines the url to the height map
  40962. * @param options defines the options used to create the mesh
  40963. * @param scene defines the hosting scene
  40964. * @returns the ground mesh
  40965. * @see https://doc.babylonjs.com/babylon101/height_map
  40966. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40967. */
  40968. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40969. width?: number;
  40970. height?: number;
  40971. subdivisions?: number;
  40972. minHeight?: number;
  40973. maxHeight?: number;
  40974. colorFilter?: Color3;
  40975. alphaFilter?: number;
  40976. updatable?: boolean;
  40977. onReady?: (mesh: GroundMesh) => void;
  40978. }, scene?: Nullable<Scene>): GroundMesh;
  40979. }
  40980. }
  40981. declare module BABYLON {
  40982. /**
  40983. * Class containing static functions to help procedurally build meshes
  40984. */
  40985. export class TorusBuilder {
  40986. /**
  40987. * Creates a torus mesh
  40988. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40989. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40990. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40991. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40992. * * 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
  40993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40994. * @param name defines the name of the mesh
  40995. * @param options defines the options used to create the mesh
  40996. * @param scene defines the hosting scene
  40997. * @returns the torus mesh
  40998. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40999. */
  41000. static CreateTorus(name: string, options: {
  41001. diameter?: number;
  41002. thickness?: number;
  41003. tessellation?: number;
  41004. updatable?: boolean;
  41005. sideOrientation?: number;
  41006. frontUVs?: Vector4;
  41007. backUVs?: Vector4;
  41008. }, scene: any): Mesh;
  41009. }
  41010. }
  41011. declare module BABYLON {
  41012. /**
  41013. * Class containing static functions to help procedurally build meshes
  41014. */
  41015. export class CylinderBuilder {
  41016. /**
  41017. * Creates a cylinder or a cone mesh
  41018. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41019. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41020. * * 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.
  41021. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41022. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41023. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41024. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41025. * * 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).
  41026. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41027. * * 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).
  41028. * * 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
  41029. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41030. * * 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
  41031. * * 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.
  41032. * * If `enclose` is false, a ring surface is one element.
  41033. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41034. * * 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
  41035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41036. * * 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
  41037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41038. * @param name defines the name of the mesh
  41039. * @param options defines the options used to create the mesh
  41040. * @param scene defines the hosting scene
  41041. * @returns the cylinder mesh
  41042. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41043. */
  41044. static CreateCylinder(name: string, options: {
  41045. height?: number;
  41046. diameterTop?: number;
  41047. diameterBottom?: number;
  41048. diameter?: number;
  41049. tessellation?: number;
  41050. subdivisions?: number;
  41051. arc?: number;
  41052. faceColors?: Color4[];
  41053. faceUV?: Vector4[];
  41054. updatable?: boolean;
  41055. hasRings?: boolean;
  41056. enclose?: boolean;
  41057. cap?: number;
  41058. sideOrientation?: number;
  41059. frontUVs?: Vector4;
  41060. backUVs?: Vector4;
  41061. }, scene: any): Mesh;
  41062. }
  41063. }
  41064. declare module BABYLON {
  41065. /**
  41066. * Options to modify the vr teleportation behavior.
  41067. */
  41068. export interface VRTeleportationOptions {
  41069. /**
  41070. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41071. */
  41072. floorMeshName?: string;
  41073. /**
  41074. * A list of meshes to be used as the teleportation floor. (default: empty)
  41075. */
  41076. floorMeshes?: Mesh[];
  41077. }
  41078. /**
  41079. * Options to modify the vr experience helper's behavior.
  41080. */
  41081. export interface VRExperienceHelperOptions extends WebVROptions {
  41082. /**
  41083. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41084. */
  41085. createDeviceOrientationCamera?: boolean;
  41086. /**
  41087. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41088. */
  41089. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41090. /**
  41091. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41092. */
  41093. laserToggle?: boolean;
  41094. /**
  41095. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41096. */
  41097. floorMeshes?: Mesh[];
  41098. /**
  41099. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41100. */
  41101. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41102. }
  41103. /**
  41104. * Event containing information after VR has been entered
  41105. */
  41106. export class OnAfterEnteringVRObservableEvent {
  41107. /**
  41108. * If entering vr was successful
  41109. */
  41110. success: boolean;
  41111. }
  41112. /**
  41113. * Helps to quickly add VR support to an existing scene.
  41114. * See http://doc.babylonjs.com/how_to/webvr_helper
  41115. */
  41116. export class VRExperienceHelper {
  41117. /** Options to modify the vr experience helper's behavior. */
  41118. webVROptions: VRExperienceHelperOptions;
  41119. private _scene;
  41120. private _position;
  41121. private _btnVR;
  41122. private _btnVRDisplayed;
  41123. private _webVRsupported;
  41124. private _webVRready;
  41125. private _webVRrequesting;
  41126. private _webVRpresenting;
  41127. private _hasEnteredVR;
  41128. private _fullscreenVRpresenting;
  41129. private _canvas;
  41130. private _webVRCamera;
  41131. private _vrDeviceOrientationCamera;
  41132. private _deviceOrientationCamera;
  41133. private _existingCamera;
  41134. private _onKeyDown;
  41135. private _onVrDisplayPresentChange;
  41136. private _onVRDisplayChanged;
  41137. private _onVRRequestPresentStart;
  41138. private _onVRRequestPresentComplete;
  41139. /**
  41140. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  41141. */
  41142. enableGazeEvenWhenNoPointerLock: boolean;
  41143. /**
  41144. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41145. */
  41146. exitVROnDoubleTap: boolean;
  41147. /**
  41148. * Observable raised right before entering VR.
  41149. */
  41150. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41151. /**
  41152. * Observable raised when entering VR has completed.
  41153. */
  41154. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41155. /**
  41156. * Observable raised when exiting VR.
  41157. */
  41158. onExitingVRObservable: Observable<VRExperienceHelper>;
  41159. /**
  41160. * Observable raised when controller mesh is loaded.
  41161. */
  41162. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41163. /** Return this.onEnteringVRObservable
  41164. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41165. */
  41166. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41167. /** Return this.onExitingVRObservable
  41168. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41169. */
  41170. readonly onExitingVR: Observable<VRExperienceHelper>;
  41171. /** Return this.onControllerMeshLoadedObservable
  41172. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41173. */
  41174. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41175. private _rayLength;
  41176. private _useCustomVRButton;
  41177. private _teleportationRequested;
  41178. private _teleportActive;
  41179. private _floorMeshName;
  41180. private _floorMeshesCollection;
  41181. private _rotationAllowed;
  41182. private _teleportBackwardsVector;
  41183. private _teleportationTarget;
  41184. private _isDefaultTeleportationTarget;
  41185. private _postProcessMove;
  41186. private _teleportationFillColor;
  41187. private _teleportationBorderColor;
  41188. private _rotationAngle;
  41189. private _haloCenter;
  41190. private _cameraGazer;
  41191. private _padSensibilityUp;
  41192. private _padSensibilityDown;
  41193. private _leftController;
  41194. private _rightController;
  41195. /**
  41196. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41197. */
  41198. onNewMeshSelected: Observable<AbstractMesh>;
  41199. /**
  41200. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  41201. * This observable will provide the mesh and the controller used to select the mesh
  41202. */
  41203. onMeshSelectedWithController: Observable<{
  41204. mesh: AbstractMesh;
  41205. controller: WebVRController;
  41206. }>;
  41207. /**
  41208. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41209. */
  41210. onNewMeshPicked: Observable<PickingInfo>;
  41211. private _circleEase;
  41212. /**
  41213. * Observable raised before camera teleportation
  41214. */
  41215. onBeforeCameraTeleport: Observable<Vector3>;
  41216. /**
  41217. * Observable raised after camera teleportation
  41218. */
  41219. onAfterCameraTeleport: Observable<Vector3>;
  41220. /**
  41221. * Observable raised when current selected mesh gets unselected
  41222. */
  41223. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41224. private _raySelectionPredicate;
  41225. /**
  41226. * To be optionaly changed by user to define custom ray selection
  41227. */
  41228. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41229. /**
  41230. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41231. */
  41232. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41233. /**
  41234. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41235. */
  41236. teleportationEnabled: boolean;
  41237. private _defaultHeight;
  41238. private _teleportationInitialized;
  41239. private _interactionsEnabled;
  41240. private _interactionsRequested;
  41241. private _displayGaze;
  41242. private _displayLaserPointer;
  41243. /**
  41244. * The mesh used to display where the user is going to teleport.
  41245. */
  41246. /**
  41247. * Sets the mesh to be used to display where the user is going to teleport.
  41248. */
  41249. teleportationTarget: Mesh;
  41250. /**
  41251. * 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
  41252. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41253. * See http://doc.babylonjs.com/resources/baking_transformations
  41254. */
  41255. gazeTrackerMesh: Mesh;
  41256. /**
  41257. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41258. */
  41259. updateGazeTrackerScale: boolean;
  41260. /**
  41261. * If the gaze trackers color should be updated when selecting meshes
  41262. */
  41263. updateGazeTrackerColor: boolean;
  41264. /**
  41265. * If the controller laser color should be updated when selecting meshes
  41266. */
  41267. updateControllerLaserColor: boolean;
  41268. /**
  41269. * The gaze tracking mesh corresponding to the left controller
  41270. */
  41271. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41272. /**
  41273. * The gaze tracking mesh corresponding to the right controller
  41274. */
  41275. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41276. /**
  41277. * If the ray of the gaze should be displayed.
  41278. */
  41279. /**
  41280. * Sets if the ray of the gaze should be displayed.
  41281. */
  41282. displayGaze: boolean;
  41283. /**
  41284. * If the ray of the LaserPointer should be displayed.
  41285. */
  41286. /**
  41287. * Sets if the ray of the LaserPointer should be displayed.
  41288. */
  41289. displayLaserPointer: boolean;
  41290. /**
  41291. * The deviceOrientationCamera used as the camera when not in VR.
  41292. */
  41293. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41294. /**
  41295. * Based on the current WebVR support, returns the current VR camera used.
  41296. */
  41297. readonly currentVRCamera: Nullable<Camera>;
  41298. /**
  41299. * The webVRCamera which is used when in VR.
  41300. */
  41301. readonly webVRCamera: WebVRFreeCamera;
  41302. /**
  41303. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41304. */
  41305. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41306. /**
  41307. * The html button that is used to trigger entering into VR.
  41308. */
  41309. readonly vrButton: Nullable<HTMLButtonElement>;
  41310. private readonly _teleportationRequestInitiated;
  41311. /**
  41312. * Defines wether or not Pointer lock should be requested when switching to
  41313. * full screen.
  41314. */
  41315. requestPointerLockOnFullScreen: boolean;
  41316. /**
  41317. * Instantiates a VRExperienceHelper.
  41318. * Helps to quickly add VR support to an existing scene.
  41319. * @param scene The scene the VRExperienceHelper belongs to.
  41320. * @param webVROptions Options to modify the vr experience helper's behavior.
  41321. */
  41322. constructor(scene: Scene,
  41323. /** Options to modify the vr experience helper's behavior. */
  41324. webVROptions?: VRExperienceHelperOptions);
  41325. private _onDefaultMeshLoaded;
  41326. private _onResize;
  41327. private _onFullscreenChange;
  41328. /**
  41329. * Gets a value indicating if we are currently in VR mode.
  41330. */
  41331. readonly isInVRMode: boolean;
  41332. private onVrDisplayPresentChange;
  41333. private onVRDisplayChanged;
  41334. private moveButtonToBottomRight;
  41335. private displayVRButton;
  41336. private updateButtonVisibility;
  41337. private _cachedAngularSensibility;
  41338. /**
  41339. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41340. * Otherwise, will use the fullscreen API.
  41341. */
  41342. enterVR(): void;
  41343. /**
  41344. * Attempt to exit VR, or fullscreen.
  41345. */
  41346. exitVR(): void;
  41347. /**
  41348. * The position of the vr experience helper.
  41349. */
  41350. /**
  41351. * Sets the position of the vr experience helper.
  41352. */
  41353. position: Vector3;
  41354. /**
  41355. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41356. */
  41357. enableInteractions(): void;
  41358. private readonly _noControllerIsActive;
  41359. private beforeRender;
  41360. private _isTeleportationFloor;
  41361. /**
  41362. * Adds a floor mesh to be used for teleportation.
  41363. * @param floorMesh the mesh to be used for teleportation.
  41364. */
  41365. addFloorMesh(floorMesh: Mesh): void;
  41366. /**
  41367. * Removes a floor mesh from being used for teleportation.
  41368. * @param floorMesh the mesh to be removed.
  41369. */
  41370. removeFloorMesh(floorMesh: Mesh): void;
  41371. /**
  41372. * Enables interactions and teleportation using the VR controllers and gaze.
  41373. * @param vrTeleportationOptions options to modify teleportation behavior.
  41374. */
  41375. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41376. private _onNewGamepadConnected;
  41377. private _tryEnableInteractionOnController;
  41378. private _onNewGamepadDisconnected;
  41379. private _enableInteractionOnController;
  41380. private _checkTeleportWithRay;
  41381. private _checkRotate;
  41382. private _checkTeleportBackwards;
  41383. private _enableTeleportationOnController;
  41384. private _createTeleportationCircles;
  41385. private _displayTeleportationTarget;
  41386. private _hideTeleportationTarget;
  41387. private _rotateCamera;
  41388. private _moveTeleportationSelectorTo;
  41389. private _workingVector;
  41390. private _workingQuaternion;
  41391. private _workingMatrix;
  41392. /**
  41393. * Teleports the users feet to the desired location
  41394. * @param location The location where the user's feet should be placed
  41395. */
  41396. teleportCamera(location: Vector3): void;
  41397. private _convertNormalToDirectionOfRay;
  41398. private _castRayAndSelectObject;
  41399. private _notifySelectedMeshUnselected;
  41400. /**
  41401. * Sets the color of the laser ray from the vr controllers.
  41402. * @param color new color for the ray.
  41403. */
  41404. changeLaserColor(color: Color3): void;
  41405. /**
  41406. * Sets the color of the ray from the vr headsets gaze.
  41407. * @param color new color for the ray.
  41408. */
  41409. changeGazeColor(color: Color3): void;
  41410. /**
  41411. * Exits VR and disposes of the vr experience helper
  41412. */
  41413. dispose(): void;
  41414. /**
  41415. * Gets the name of the VRExperienceHelper class
  41416. * @returns "VRExperienceHelper"
  41417. */
  41418. getClassName(): string;
  41419. }
  41420. }
  41421. declare module BABYLON {
  41422. /**
  41423. * Manages an XRSession to work with Babylon's engine
  41424. * @see https://doc.babylonjs.com/how_to/webxr
  41425. */
  41426. export class WebXRSessionManager implements IDisposable {
  41427. private scene;
  41428. /**
  41429. * Fires every time a new xrFrame arrives which can be used to update the camera
  41430. */
  41431. onXRFrameObservable: Observable<any>;
  41432. /**
  41433. * Fires when the xr session is ended either by the device or manually done
  41434. */
  41435. onXRSessionEnded: Observable<any>;
  41436. /**
  41437. * Underlying xr session
  41438. */
  41439. session: XRSession;
  41440. /**
  41441. * Type of reference space used when creating the session
  41442. */
  41443. referenceSpace: XRReferenceSpace;
  41444. /** @hidden */
  41445. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41446. /**
  41447. * Current XR frame
  41448. */
  41449. currentFrame: Nullable<XRFrame>;
  41450. private _xrNavigator;
  41451. private baseLayer;
  41452. /**
  41453. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41454. * @param scene The scene which the session should be created for
  41455. */
  41456. constructor(scene: Scene);
  41457. /**
  41458. * Initializes the manager
  41459. * After initialization enterXR can be called to start an XR session
  41460. * @returns Promise which resolves after it is initialized
  41461. */
  41462. initializeAsync(): Promise<void>;
  41463. /**
  41464. * Initializes an xr session
  41465. * @param xrSessionMode mode to initialize
  41466. * @returns a promise which will resolve once the session has been initialized
  41467. */
  41468. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41469. /**
  41470. * Sets the reference space on the xr session
  41471. * @param referenceSpace space to set
  41472. * @returns a promise that will resolve once the reference space has been set
  41473. */
  41474. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41475. /**
  41476. * Updates the render state of the session
  41477. * @param state state to set
  41478. * @returns a promise that resolves once the render state has been updated
  41479. */
  41480. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41481. /**
  41482. * Starts rendering to the xr layer
  41483. * @returns a promise that will resolve once rendering has started
  41484. */
  41485. startRenderingToXRAsync(): Promise<void>;
  41486. /**
  41487. * Stops the xrSession and restores the renderloop
  41488. * @returns Promise which resolves after it exits XR
  41489. */
  41490. exitXRAsync(): Promise<unknown>;
  41491. /**
  41492. * Checks if a session would be supported for the creation options specified
  41493. * @param sessionMode session mode to check if supported eg. immersive-vr
  41494. * @returns true if supported
  41495. */
  41496. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41497. /**
  41498. * @hidden
  41499. * Converts the render layer of xrSession to a render target
  41500. * @param session session to create render target for
  41501. * @param scene scene the new render target should be created for
  41502. */
  41503. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41504. /**
  41505. * Disposes of the session manager
  41506. */
  41507. dispose(): void;
  41508. }
  41509. }
  41510. declare module BABYLON {
  41511. /**
  41512. * WebXR Camera which holds the views for the xrSession
  41513. * @see https://doc.babylonjs.com/how_to/webxr
  41514. */
  41515. export class WebXRCamera extends FreeCamera {
  41516. private static _TmpMatrix;
  41517. /**
  41518. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41519. * @param name the name of the camera
  41520. * @param scene the scene to add the camera to
  41521. */
  41522. constructor(name: string, scene: Scene);
  41523. private _updateNumberOfRigCameras;
  41524. /** @hidden */
  41525. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41526. /**
  41527. * Updates the cameras position from the current pose information of the XR session
  41528. * @param xrSessionManager the session containing pose information
  41529. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41530. */
  41531. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41532. }
  41533. }
  41534. declare module BABYLON {
  41535. /**
  41536. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41537. */
  41538. export class WebXRManagedOutputCanvas implements IDisposable {
  41539. private helper;
  41540. private _canvas;
  41541. /**
  41542. * xrpresent context of the canvas which can be used to display/mirror xr content
  41543. */
  41544. canvasContext: WebGLRenderingContext;
  41545. /**
  41546. * xr layer for the canvas
  41547. */
  41548. xrLayer: Nullable<XRWebGLLayer>;
  41549. /**
  41550. * Initializes the xr layer for the session
  41551. * @param xrSession xr session
  41552. * @returns a promise that will resolve once the XR Layer has been created
  41553. */
  41554. initializeXRLayerAsync(xrSession: any): any;
  41555. /**
  41556. * Initializes the canvas to be added/removed upon entering/exiting xr
  41557. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41558. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41559. */
  41560. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41561. /**
  41562. * Disposes of the object
  41563. */
  41564. dispose(): void;
  41565. private _setManagedOutputCanvas;
  41566. private _addCanvas;
  41567. private _removeCanvas;
  41568. }
  41569. }
  41570. declare module BABYLON {
  41571. /**
  41572. * States of the webXR experience
  41573. */
  41574. export enum WebXRState {
  41575. /**
  41576. * Transitioning to being in XR mode
  41577. */
  41578. ENTERING_XR = 0,
  41579. /**
  41580. * Transitioning to non XR mode
  41581. */
  41582. EXITING_XR = 1,
  41583. /**
  41584. * In XR mode and presenting
  41585. */
  41586. IN_XR = 2,
  41587. /**
  41588. * Not entered XR mode
  41589. */
  41590. NOT_IN_XR = 3
  41591. }
  41592. /**
  41593. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41594. * @see https://doc.babylonjs.com/how_to/webxr
  41595. */
  41596. export class WebXRExperienceHelper implements IDisposable {
  41597. private scene;
  41598. /**
  41599. * 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
  41600. */
  41601. container: AbstractMesh;
  41602. /**
  41603. * Camera used to render xr content
  41604. */
  41605. camera: WebXRCamera;
  41606. /**
  41607. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41608. */
  41609. state: WebXRState;
  41610. private _setState;
  41611. private static _TmpVector;
  41612. /**
  41613. * Fires when the state of the experience helper has changed
  41614. */
  41615. onStateChangedObservable: Observable<WebXRState>;
  41616. /** Session manager used to keep track of xr session */
  41617. sessionManager: WebXRSessionManager;
  41618. private _nonVRCamera;
  41619. private _originalSceneAutoClear;
  41620. private _supported;
  41621. /**
  41622. * Creates the experience helper
  41623. * @param scene the scene to attach the experience helper to
  41624. * @returns a promise for the experience helper
  41625. */
  41626. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41627. /**
  41628. * Creates a WebXRExperienceHelper
  41629. * @param scene The scene the helper should be created in
  41630. */
  41631. private constructor();
  41632. /**
  41633. * Exits XR mode and returns the scene to its original state
  41634. * @returns promise that resolves after xr mode has exited
  41635. */
  41636. exitXRAsync(): Promise<unknown>;
  41637. /**
  41638. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41639. * @param sessionCreationOptions options for the XR session
  41640. * @param referenceSpaceType frame of reference of the XR session
  41641. * @param outputCanvas the output canvas that will be used to enter XR mode
  41642. * @returns promise that resolves after xr mode has entered
  41643. */
  41644. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41645. /**
  41646. * Updates the global position of the camera by moving the camera's container
  41647. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41648. * @param position The desired global position of the camera
  41649. */
  41650. setPositionOfCameraUsingContainer(position: Vector3): void;
  41651. /**
  41652. * Rotates the xr camera by rotating the camera's container around the camera's position
  41653. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41654. * @param rotation the desired quaternion rotation to apply to the camera
  41655. */
  41656. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41657. /**
  41658. * Disposes of the experience helper
  41659. */
  41660. dispose(): void;
  41661. }
  41662. }
  41663. declare module BABYLON {
  41664. /**
  41665. * Button which can be used to enter a different mode of XR
  41666. */
  41667. export class WebXREnterExitUIButton {
  41668. /** button element */
  41669. element: HTMLElement;
  41670. /** XR initialization options for the button */
  41671. sessionMode: XRSessionMode;
  41672. /** Reference space type */
  41673. referenceSpaceType: XRReferenceSpaceType;
  41674. /**
  41675. * Creates a WebXREnterExitUIButton
  41676. * @param element button element
  41677. * @param sessionMode XR initialization session mode
  41678. * @param referenceSpaceType the type of reference space to be used
  41679. */
  41680. constructor(
  41681. /** button element */
  41682. element: HTMLElement,
  41683. /** XR initialization options for the button */
  41684. sessionMode: XRSessionMode,
  41685. /** Reference space type */
  41686. referenceSpaceType: XRReferenceSpaceType);
  41687. /**
  41688. * Overwritable function which can be used to update the button's visuals when the state changes
  41689. * @param activeButton the current active button in the UI
  41690. */
  41691. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41692. }
  41693. /**
  41694. * Options to create the webXR UI
  41695. */
  41696. export class WebXREnterExitUIOptions {
  41697. /**
  41698. * Context to enter xr with
  41699. */
  41700. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41701. /**
  41702. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41703. */
  41704. customButtons?: Array<WebXREnterExitUIButton>;
  41705. }
  41706. /**
  41707. * UI to allow the user to enter/exit XR mode
  41708. */
  41709. export class WebXREnterExitUI implements IDisposable {
  41710. private scene;
  41711. private _overlay;
  41712. private _buttons;
  41713. private _activeButton;
  41714. /**
  41715. * Fired every time the active button is changed.
  41716. *
  41717. * When xr is entered via a button that launches xr that button will be the callback parameter
  41718. *
  41719. * When exiting xr the callback parameter will be null)
  41720. */
  41721. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41722. /**
  41723. * Creates UI to allow the user to enter/exit XR mode
  41724. * @param scene the scene to add the ui to
  41725. * @param helper the xr experience helper to enter/exit xr with
  41726. * @param options options to configure the UI
  41727. * @returns the created ui
  41728. */
  41729. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41730. private constructor();
  41731. private _updateButtons;
  41732. /**
  41733. * Disposes of the object
  41734. */
  41735. dispose(): void;
  41736. }
  41737. }
  41738. declare module BABYLON {
  41739. /**
  41740. * Represents an XR input
  41741. */
  41742. export class WebXRController {
  41743. private scene;
  41744. /** The underlying input source for the controller */
  41745. inputSource: XRInputSource;
  41746. private parentContainer;
  41747. /**
  41748. * 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
  41749. */
  41750. grip?: AbstractMesh;
  41751. /**
  41752. * Pointer which can be used to select objects or attach a visible laser to
  41753. */
  41754. pointer: AbstractMesh;
  41755. /**
  41756. * Event that fires when the controller is removed/disposed
  41757. */
  41758. onDisposeObservable: Observable<{}>;
  41759. private _tmpMatrix;
  41760. private _tmpQuaternion;
  41761. private _tmpVector;
  41762. /**
  41763. * Creates the controller
  41764. * @see https://doc.babylonjs.com/how_to/webxr
  41765. * @param scene the scene which the controller should be associated to
  41766. * @param inputSource the underlying input source for the controller
  41767. * @param parentContainer parent that the controller meshes should be children of
  41768. */
  41769. constructor(scene: Scene,
  41770. /** The underlying input source for the controller */
  41771. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41772. /**
  41773. * Updates the controller pose based on the given XRFrame
  41774. * @param xrFrame xr frame to update the pose with
  41775. * @param referenceSpace reference space to use
  41776. */
  41777. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41778. /**
  41779. * Gets a world space ray coming from the controller
  41780. * @param result the resulting ray
  41781. */
  41782. getWorldPointerRayToRef(result: Ray): void;
  41783. /**
  41784. * Disposes of the object
  41785. */
  41786. dispose(): void;
  41787. }
  41788. }
  41789. declare module BABYLON {
  41790. /**
  41791. * XR input used to track XR inputs such as controllers/rays
  41792. */
  41793. export class WebXRInput implements IDisposable {
  41794. /**
  41795. * Base experience the input listens to
  41796. */
  41797. baseExperience: WebXRExperienceHelper;
  41798. /**
  41799. * XR controllers being tracked
  41800. */
  41801. controllers: Array<WebXRController>;
  41802. private _frameObserver;
  41803. private _stateObserver;
  41804. /**
  41805. * Event when a controller has been connected/added
  41806. */
  41807. onControllerAddedObservable: Observable<WebXRController>;
  41808. /**
  41809. * Event when a controller has been removed/disconnected
  41810. */
  41811. onControllerRemovedObservable: Observable<WebXRController>;
  41812. /**
  41813. * Initializes the WebXRInput
  41814. * @param baseExperience experience helper which the input should be created for
  41815. */
  41816. constructor(
  41817. /**
  41818. * Base experience the input listens to
  41819. */
  41820. baseExperience: WebXRExperienceHelper);
  41821. private _onInputSourcesChange;
  41822. private _addAndRemoveControllers;
  41823. /**
  41824. * Disposes of the object
  41825. */
  41826. dispose(): void;
  41827. }
  41828. }
  41829. declare module BABYLON {
  41830. /**
  41831. * Enables teleportation
  41832. */
  41833. export class WebXRControllerTeleportation {
  41834. private _teleportationFillColor;
  41835. private _teleportationBorderColor;
  41836. private _tmpRay;
  41837. private _tmpVector;
  41838. /**
  41839. * Creates a WebXRControllerTeleportation
  41840. * @param input input manager to add teleportation to
  41841. * @param floorMeshes floormeshes which can be teleported to
  41842. */
  41843. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41844. }
  41845. }
  41846. declare module BABYLON {
  41847. /**
  41848. * Handles pointer input automatically for the pointer of XR controllers
  41849. */
  41850. export class WebXRControllerPointerSelection {
  41851. private static _idCounter;
  41852. private _tmpRay;
  41853. /**
  41854. * Creates a WebXRControllerPointerSelection
  41855. * @param input input manager to setup pointer selection
  41856. */
  41857. constructor(input: WebXRInput);
  41858. private _convertNormalToDirectionOfRay;
  41859. private _updatePointerDistance;
  41860. }
  41861. }
  41862. declare module BABYLON {
  41863. /**
  41864. * Class used to represent data loading progression
  41865. */
  41866. export class SceneLoaderProgressEvent {
  41867. /** defines if data length to load can be evaluated */
  41868. readonly lengthComputable: boolean;
  41869. /** defines the loaded data length */
  41870. readonly loaded: number;
  41871. /** defines the data length to load */
  41872. readonly total: number;
  41873. /**
  41874. * Create a new progress event
  41875. * @param lengthComputable defines if data length to load can be evaluated
  41876. * @param loaded defines the loaded data length
  41877. * @param total defines the data length to load
  41878. */
  41879. constructor(
  41880. /** defines if data length to load can be evaluated */
  41881. lengthComputable: boolean,
  41882. /** defines the loaded data length */
  41883. loaded: number,
  41884. /** defines the data length to load */
  41885. total: number);
  41886. /**
  41887. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41888. * @param event defines the source event
  41889. * @returns a new SceneLoaderProgressEvent
  41890. */
  41891. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41892. }
  41893. /**
  41894. * Interface used by SceneLoader plugins to define supported file extensions
  41895. */
  41896. export interface ISceneLoaderPluginExtensions {
  41897. /**
  41898. * Defines the list of supported extensions
  41899. */
  41900. [extension: string]: {
  41901. isBinary: boolean;
  41902. };
  41903. }
  41904. /**
  41905. * Interface used by SceneLoader plugin factory
  41906. */
  41907. export interface ISceneLoaderPluginFactory {
  41908. /**
  41909. * Defines the name of the factory
  41910. */
  41911. name: string;
  41912. /**
  41913. * Function called to create a new plugin
  41914. * @return the new plugin
  41915. */
  41916. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41917. /**
  41918. * Boolean indicating if the plugin can direct load specific data
  41919. */
  41920. canDirectLoad?: (data: string) => boolean;
  41921. }
  41922. /**
  41923. * Interface used to define a SceneLoader plugin
  41924. */
  41925. export interface ISceneLoaderPlugin {
  41926. /**
  41927. * The friendly name of this plugin.
  41928. */
  41929. name: string;
  41930. /**
  41931. * The file extensions supported by this plugin.
  41932. */
  41933. extensions: string | ISceneLoaderPluginExtensions;
  41934. /**
  41935. * Import meshes into a scene.
  41936. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41937. * @param scene The scene to import into
  41938. * @param data The data to import
  41939. * @param rootUrl The root url for scene and resources
  41940. * @param meshes The meshes array to import into
  41941. * @param particleSystems The particle systems array to import into
  41942. * @param skeletons The skeletons array to import into
  41943. * @param onError The callback when import fails
  41944. * @returns True if successful or false otherwise
  41945. */
  41946. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41947. /**
  41948. * Load into a scene.
  41949. * @param scene The scene to load into
  41950. * @param data The data to import
  41951. * @param rootUrl The root url for scene and resources
  41952. * @param onError The callback when import fails
  41953. * @returns true if successful or false otherwise
  41954. */
  41955. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41956. /**
  41957. * The callback that returns true if the data can be directly loaded.
  41958. */
  41959. canDirectLoad?: (data: string) => boolean;
  41960. /**
  41961. * The callback that allows custom handling of the root url based on the response url.
  41962. */
  41963. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41964. /**
  41965. * Load into an asset container.
  41966. * @param scene The scene to load into
  41967. * @param data The data to import
  41968. * @param rootUrl The root url for scene and resources
  41969. * @param onError The callback when import fails
  41970. * @returns The loaded asset container
  41971. */
  41972. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41973. }
  41974. /**
  41975. * Interface used to define an async SceneLoader plugin
  41976. */
  41977. export interface ISceneLoaderPluginAsync {
  41978. /**
  41979. * The friendly name of this plugin.
  41980. */
  41981. name: string;
  41982. /**
  41983. * The file extensions supported by this plugin.
  41984. */
  41985. extensions: string | ISceneLoaderPluginExtensions;
  41986. /**
  41987. * Import meshes into a scene.
  41988. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41989. * @param scene The scene to import into
  41990. * @param data The data to import
  41991. * @param rootUrl The root url for scene and resources
  41992. * @param onProgress The callback when the load progresses
  41993. * @param fileName Defines the name of the file to load
  41994. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41995. */
  41996. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41997. meshes: AbstractMesh[];
  41998. particleSystems: IParticleSystem[];
  41999. skeletons: Skeleton[];
  42000. animationGroups: AnimationGroup[];
  42001. }>;
  42002. /**
  42003. * Load into a scene.
  42004. * @param scene The scene to load into
  42005. * @param data The data to import
  42006. * @param rootUrl The root url for scene and resources
  42007. * @param onProgress The callback when the load progresses
  42008. * @param fileName Defines the name of the file to load
  42009. * @returns Nothing
  42010. */
  42011. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42012. /**
  42013. * The callback that returns true if the data can be directly loaded.
  42014. */
  42015. canDirectLoad?: (data: string) => boolean;
  42016. /**
  42017. * The callback that allows custom handling of the root url based on the response url.
  42018. */
  42019. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42020. /**
  42021. * Load into an asset container.
  42022. * @param scene The scene to load into
  42023. * @param data The data to import
  42024. * @param rootUrl The root url for scene and resources
  42025. * @param onProgress The callback when the load progresses
  42026. * @param fileName Defines the name of the file to load
  42027. * @returns The loaded asset container
  42028. */
  42029. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42030. }
  42031. /**
  42032. * Class used to load scene from various file formats using registered plugins
  42033. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42034. */
  42035. export class SceneLoader {
  42036. /**
  42037. * No logging while loading
  42038. */
  42039. static readonly NO_LOGGING: number;
  42040. /**
  42041. * Minimal logging while loading
  42042. */
  42043. static readonly MINIMAL_LOGGING: number;
  42044. /**
  42045. * Summary logging while loading
  42046. */
  42047. static readonly SUMMARY_LOGGING: number;
  42048. /**
  42049. * Detailled logging while loading
  42050. */
  42051. static readonly DETAILED_LOGGING: number;
  42052. /**
  42053. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42054. */
  42055. static ForceFullSceneLoadingForIncremental: boolean;
  42056. /**
  42057. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42058. */
  42059. static ShowLoadingScreen: boolean;
  42060. /**
  42061. * Defines the current logging level (while loading the scene)
  42062. * @ignorenaming
  42063. */
  42064. static loggingLevel: number;
  42065. /**
  42066. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42067. */
  42068. static CleanBoneMatrixWeights: boolean;
  42069. /**
  42070. * Event raised when a plugin is used to load a scene
  42071. */
  42072. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42073. private static _registeredPlugins;
  42074. private static _getDefaultPlugin;
  42075. private static _getPluginForExtension;
  42076. private static _getPluginForDirectLoad;
  42077. private static _getPluginForFilename;
  42078. private static _getDirectLoad;
  42079. private static _loadData;
  42080. private static _getFileInfo;
  42081. /**
  42082. * Gets a plugin that can load the given extension
  42083. * @param extension defines the extension to load
  42084. * @returns a plugin or null if none works
  42085. */
  42086. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42087. /**
  42088. * Gets a boolean indicating that the given extension can be loaded
  42089. * @param extension defines the extension to load
  42090. * @returns true if the extension is supported
  42091. */
  42092. static IsPluginForExtensionAvailable(extension: string): boolean;
  42093. /**
  42094. * Adds a new plugin to the list of registered plugins
  42095. * @param plugin defines the plugin to add
  42096. */
  42097. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42098. /**
  42099. * Import meshes into a scene
  42100. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42101. * @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)
  42102. * @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)
  42103. * @param scene the instance of BABYLON.Scene to append to
  42104. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42105. * @param onProgress a callback with a progress event for each file being loaded
  42106. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42107. * @param pluginExtension the extension used to determine the plugin
  42108. * @returns The loaded plugin
  42109. */
  42110. 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>;
  42111. /**
  42112. * Import meshes into a scene
  42113. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42114. * @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)
  42115. * @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)
  42116. * @param scene the instance of BABYLON.Scene to append to
  42117. * @param onProgress a callback with a progress event for each file being loaded
  42118. * @param pluginExtension the extension used to determine the plugin
  42119. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42120. */
  42121. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42122. meshes: AbstractMesh[];
  42123. particleSystems: IParticleSystem[];
  42124. skeletons: Skeleton[];
  42125. animationGroups: AnimationGroup[];
  42126. }>;
  42127. /**
  42128. * Load a scene
  42129. * @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)
  42130. * @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)
  42131. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42132. * @param onSuccess a callback with the scene when import succeeds
  42133. * @param onProgress a callback with a progress event for each file being loaded
  42134. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42135. * @param pluginExtension the extension used to determine the plugin
  42136. * @returns The loaded plugin
  42137. */
  42138. 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>;
  42139. /**
  42140. * Load a scene
  42141. * @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)
  42142. * @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)
  42143. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42144. * @param onProgress a callback with a progress event for each file being loaded
  42145. * @param pluginExtension the extension used to determine the plugin
  42146. * @returns The loaded scene
  42147. */
  42148. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42149. /**
  42150. * Append a scene
  42151. * @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)
  42152. * @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)
  42153. * @param scene is the instance of BABYLON.Scene to append to
  42154. * @param onSuccess a callback with the scene when import succeeds
  42155. * @param onProgress a callback with a progress event for each file being loaded
  42156. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42157. * @param pluginExtension the extension used to determine the plugin
  42158. * @returns The loaded plugin
  42159. */
  42160. 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>;
  42161. /**
  42162. * Append a scene
  42163. * @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)
  42164. * @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)
  42165. * @param scene is the instance of BABYLON.Scene to append to
  42166. * @param onProgress a callback with a progress event for each file being loaded
  42167. * @param pluginExtension the extension used to determine the plugin
  42168. * @returns The given scene
  42169. */
  42170. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42171. /**
  42172. * Load a scene into an asset container
  42173. * @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)
  42174. * @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)
  42175. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42176. * @param onSuccess a callback with the scene when import succeeds
  42177. * @param onProgress a callback with a progress event for each file being loaded
  42178. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42179. * @param pluginExtension the extension used to determine the plugin
  42180. * @returns The loaded plugin
  42181. */
  42182. 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>;
  42183. /**
  42184. * Load a scene into an asset container
  42185. * @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)
  42186. * @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)
  42187. * @param scene is the instance of Scene to append to
  42188. * @param onProgress a callback with a progress event for each file being loaded
  42189. * @param pluginExtension the extension used to determine the plugin
  42190. * @returns The loaded asset container
  42191. */
  42192. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42193. }
  42194. }
  42195. declare module BABYLON {
  42196. /**
  42197. * Generic Controller
  42198. */
  42199. export class GenericController extends WebVRController {
  42200. /**
  42201. * Base Url for the controller model.
  42202. */
  42203. static readonly MODEL_BASE_URL: string;
  42204. /**
  42205. * File name for the controller model.
  42206. */
  42207. static readonly MODEL_FILENAME: string;
  42208. /**
  42209. * Creates a new GenericController from a gamepad
  42210. * @param vrGamepad the gamepad that the controller should be created from
  42211. */
  42212. constructor(vrGamepad: any);
  42213. /**
  42214. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42215. * @param scene scene in which to add meshes
  42216. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42217. */
  42218. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42219. /**
  42220. * Called once for each button that changed state since the last frame
  42221. * @param buttonIdx Which button index changed
  42222. * @param state New state of the button
  42223. * @param changes Which properties on the state changed since last frame
  42224. */
  42225. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42226. }
  42227. }
  42228. declare module BABYLON {
  42229. /**
  42230. * Defines the WindowsMotionController object that the state of the windows motion controller
  42231. */
  42232. export class WindowsMotionController extends WebVRController {
  42233. /**
  42234. * The base url used to load the left and right controller models
  42235. */
  42236. static MODEL_BASE_URL: string;
  42237. /**
  42238. * The name of the left controller model file
  42239. */
  42240. static MODEL_LEFT_FILENAME: string;
  42241. /**
  42242. * The name of the right controller model file
  42243. */
  42244. static MODEL_RIGHT_FILENAME: string;
  42245. /**
  42246. * The controller name prefix for this controller type
  42247. */
  42248. static readonly GAMEPAD_ID_PREFIX: string;
  42249. /**
  42250. * The controller id pattern for this controller type
  42251. */
  42252. private static readonly GAMEPAD_ID_PATTERN;
  42253. private _loadedMeshInfo;
  42254. private readonly _mapping;
  42255. /**
  42256. * Fired when the trackpad on this controller is clicked
  42257. */
  42258. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42259. /**
  42260. * Fired when the trackpad on this controller is modified
  42261. */
  42262. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42263. /**
  42264. * The current x and y values of this controller's trackpad
  42265. */
  42266. trackpad: StickValues;
  42267. /**
  42268. * Creates a new WindowsMotionController from a gamepad
  42269. * @param vrGamepad the gamepad that the controller should be created from
  42270. */
  42271. constructor(vrGamepad: any);
  42272. /**
  42273. * Fired when the trigger on this controller is modified
  42274. */
  42275. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42276. /**
  42277. * Fired when the menu button on this controller is modified
  42278. */
  42279. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42280. /**
  42281. * Fired when the grip button on this controller is modified
  42282. */
  42283. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42284. /**
  42285. * Fired when the thumbstick button on this controller is modified
  42286. */
  42287. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42288. /**
  42289. * Fired when the touchpad button on this controller is modified
  42290. */
  42291. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42292. /**
  42293. * Fired when the touchpad values on this controller are modified
  42294. */
  42295. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42296. private _updateTrackpad;
  42297. /**
  42298. * Called once per frame by the engine.
  42299. */
  42300. update(): void;
  42301. /**
  42302. * Called once for each button that changed state since the last frame
  42303. * @param buttonIdx Which button index changed
  42304. * @param state New state of the button
  42305. * @param changes Which properties on the state changed since last frame
  42306. */
  42307. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42308. /**
  42309. * Moves the buttons on the controller mesh based on their current state
  42310. * @param buttonName the name of the button to move
  42311. * @param buttonValue the value of the button which determines the buttons new position
  42312. */
  42313. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42314. /**
  42315. * Moves the axis on the controller mesh based on its current state
  42316. * @param axis the index of the axis
  42317. * @param axisValue the value of the axis which determines the meshes new position
  42318. * @hidden
  42319. */
  42320. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42321. /**
  42322. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42323. * @param scene scene in which to add meshes
  42324. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42325. */
  42326. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42327. /**
  42328. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42329. * can be transformed by button presses and axes values, based on this._mapping.
  42330. *
  42331. * @param scene scene in which the meshes exist
  42332. * @param meshes list of meshes that make up the controller model to process
  42333. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42334. */
  42335. private processModel;
  42336. private createMeshInfo;
  42337. /**
  42338. * Gets the ray of the controller in the direction the controller is pointing
  42339. * @param length the length the resulting ray should be
  42340. * @returns a ray in the direction the controller is pointing
  42341. */
  42342. getForwardRay(length?: number): Ray;
  42343. /**
  42344. * Disposes of the controller
  42345. */
  42346. dispose(): void;
  42347. }
  42348. }
  42349. declare module BABYLON {
  42350. /**
  42351. * Oculus Touch Controller
  42352. */
  42353. export class OculusTouchController extends WebVRController {
  42354. /**
  42355. * Base Url for the controller model.
  42356. */
  42357. static MODEL_BASE_URL: string;
  42358. /**
  42359. * File name for the left controller model.
  42360. */
  42361. static MODEL_LEFT_FILENAME: string;
  42362. /**
  42363. * File name for the right controller model.
  42364. */
  42365. static MODEL_RIGHT_FILENAME: string;
  42366. /**
  42367. * Base Url for the Quest controller model.
  42368. */
  42369. static QUEST_MODEL_BASE_URL: string;
  42370. /**
  42371. * @hidden
  42372. * If the controllers are running on a device that needs the updated Quest controller models
  42373. */
  42374. static _IsQuest: boolean;
  42375. /**
  42376. * Fired when the secondary trigger on this controller is modified
  42377. */
  42378. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42379. /**
  42380. * Fired when the thumb rest on this controller is modified
  42381. */
  42382. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42383. /**
  42384. * Creates a new OculusTouchController from a gamepad
  42385. * @param vrGamepad the gamepad that the controller should be created from
  42386. */
  42387. constructor(vrGamepad: any);
  42388. /**
  42389. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42390. * @param scene scene in which to add meshes
  42391. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42392. */
  42393. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42394. /**
  42395. * Fired when the A button on this controller is modified
  42396. */
  42397. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42398. /**
  42399. * Fired when the B button on this controller is modified
  42400. */
  42401. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42402. /**
  42403. * Fired when the X button on this controller is modified
  42404. */
  42405. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42406. /**
  42407. * Fired when the Y button on this controller is modified
  42408. */
  42409. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42410. /**
  42411. * Called once for each button that changed state since the last frame
  42412. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42413. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42414. * 2) secondary trigger (same)
  42415. * 3) A (right) X (left), touch, pressed = value
  42416. * 4) B / Y
  42417. * 5) thumb rest
  42418. * @param buttonIdx Which button index changed
  42419. * @param state New state of the button
  42420. * @param changes Which properties on the state changed since last frame
  42421. */
  42422. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42423. }
  42424. }
  42425. declare module BABYLON {
  42426. /**
  42427. * Vive Controller
  42428. */
  42429. export class ViveController extends WebVRController {
  42430. /**
  42431. * Base Url for the controller model.
  42432. */
  42433. static MODEL_BASE_URL: string;
  42434. /**
  42435. * File name for the controller model.
  42436. */
  42437. static MODEL_FILENAME: string;
  42438. /**
  42439. * Creates a new ViveController from a gamepad
  42440. * @param vrGamepad the gamepad that the controller should be created from
  42441. */
  42442. constructor(vrGamepad: any);
  42443. /**
  42444. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42445. * @param scene scene in which to add meshes
  42446. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42447. */
  42448. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42449. /**
  42450. * Fired when the left button on this controller is modified
  42451. */
  42452. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42453. /**
  42454. * Fired when the right button on this controller is modified
  42455. */
  42456. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42457. /**
  42458. * Fired when the menu button on this controller is modified
  42459. */
  42460. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42461. /**
  42462. * Called once for each button that changed state since the last frame
  42463. * Vive mapping:
  42464. * 0: touchpad
  42465. * 1: trigger
  42466. * 2: left AND right buttons
  42467. * 3: menu button
  42468. * @param buttonIdx Which button index changed
  42469. * @param state New state of the button
  42470. * @param changes Which properties on the state changed since last frame
  42471. */
  42472. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42473. }
  42474. }
  42475. declare module BABYLON {
  42476. /**
  42477. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42478. */
  42479. export class WebXRControllerModelLoader {
  42480. /**
  42481. * Creates the WebXRControllerModelLoader
  42482. * @param input xr input that creates the controllers
  42483. */
  42484. constructor(input: WebXRInput);
  42485. }
  42486. }
  42487. declare module BABYLON {
  42488. /**
  42489. * Contains an array of blocks representing the octree
  42490. */
  42491. export interface IOctreeContainer<T> {
  42492. /**
  42493. * Blocks within the octree
  42494. */
  42495. blocks: Array<OctreeBlock<T>>;
  42496. }
  42497. /**
  42498. * Class used to store a cell in an octree
  42499. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42500. */
  42501. export class OctreeBlock<T> {
  42502. /**
  42503. * Gets the content of the current block
  42504. */
  42505. entries: T[];
  42506. /**
  42507. * Gets the list of block children
  42508. */
  42509. blocks: Array<OctreeBlock<T>>;
  42510. private _depth;
  42511. private _maxDepth;
  42512. private _capacity;
  42513. private _minPoint;
  42514. private _maxPoint;
  42515. private _boundingVectors;
  42516. private _creationFunc;
  42517. /**
  42518. * Creates a new block
  42519. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42520. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42521. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42522. * @param depth defines the current depth of this block in the octree
  42523. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42524. * @param creationFunc defines a callback to call when an element is added to the block
  42525. */
  42526. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42527. /**
  42528. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42529. */
  42530. readonly capacity: number;
  42531. /**
  42532. * Gets the minimum vector (in world space) of the block's bounding box
  42533. */
  42534. readonly minPoint: Vector3;
  42535. /**
  42536. * Gets the maximum vector (in world space) of the block's bounding box
  42537. */
  42538. readonly maxPoint: Vector3;
  42539. /**
  42540. * Add a new element to this block
  42541. * @param entry defines the element to add
  42542. */
  42543. addEntry(entry: T): void;
  42544. /**
  42545. * Remove an element from this block
  42546. * @param entry defines the element to remove
  42547. */
  42548. removeEntry(entry: T): void;
  42549. /**
  42550. * Add an array of elements to this block
  42551. * @param entries defines the array of elements to add
  42552. */
  42553. addEntries(entries: T[]): void;
  42554. /**
  42555. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42556. * @param frustumPlanes defines the frustum planes to test
  42557. * @param selection defines the array to store current content if selection is positive
  42558. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42559. */
  42560. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42561. /**
  42562. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42563. * @param sphereCenter defines the bounding sphere center
  42564. * @param sphereRadius defines the bounding sphere radius
  42565. * @param selection defines the array to store current content if selection is positive
  42566. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42567. */
  42568. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42569. /**
  42570. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42571. * @param ray defines the ray to test with
  42572. * @param selection defines the array to store current content if selection is positive
  42573. */
  42574. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42575. /**
  42576. * Subdivide the content into child blocks (this block will then be empty)
  42577. */
  42578. createInnerBlocks(): void;
  42579. /**
  42580. * @hidden
  42581. */
  42582. 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;
  42583. }
  42584. }
  42585. declare module BABYLON {
  42586. /**
  42587. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42588. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42589. */
  42590. export class Octree<T> {
  42591. /** 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.) */
  42592. maxDepth: number;
  42593. /**
  42594. * Blocks within the octree containing objects
  42595. */
  42596. blocks: Array<OctreeBlock<T>>;
  42597. /**
  42598. * Content stored in the octree
  42599. */
  42600. dynamicContent: T[];
  42601. private _maxBlockCapacity;
  42602. private _selectionContent;
  42603. private _creationFunc;
  42604. /**
  42605. * Creates a octree
  42606. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42607. * @param creationFunc function to be used to instatiate the octree
  42608. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42609. * @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.)
  42610. */
  42611. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42612. /** 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.) */
  42613. maxDepth?: number);
  42614. /**
  42615. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42616. * @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);
  42617. * @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);
  42618. * @param entries meshes to be added to the octree blocks
  42619. */
  42620. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42621. /**
  42622. * Adds a mesh to the octree
  42623. * @param entry Mesh to add to the octree
  42624. */
  42625. addMesh(entry: T): void;
  42626. /**
  42627. * Remove an element from the octree
  42628. * @param entry defines the element to remove
  42629. */
  42630. removeMesh(entry: T): void;
  42631. /**
  42632. * Selects an array of meshes within the frustum
  42633. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42634. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42635. * @returns array of meshes within the frustum
  42636. */
  42637. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42638. /**
  42639. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42640. * @param sphereCenter defines the bounding sphere center
  42641. * @param sphereRadius defines the bounding sphere radius
  42642. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42643. * @returns an array of objects that intersect the sphere
  42644. */
  42645. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42646. /**
  42647. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42648. * @param ray defines the ray to test with
  42649. * @returns array of intersected objects
  42650. */
  42651. intersectsRay(ray: Ray): SmartArray<T>;
  42652. /**
  42653. * Adds a mesh into the octree block if it intersects the block
  42654. */
  42655. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42656. /**
  42657. * Adds a submesh into the octree block if it intersects the block
  42658. */
  42659. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42660. }
  42661. }
  42662. declare module BABYLON {
  42663. interface Scene {
  42664. /**
  42665. * @hidden
  42666. * Backing Filed
  42667. */
  42668. _selectionOctree: Octree<AbstractMesh>;
  42669. /**
  42670. * Gets the octree used to boost mesh selection (picking)
  42671. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42672. */
  42673. selectionOctree: Octree<AbstractMesh>;
  42674. /**
  42675. * Creates or updates the octree used to boost selection (picking)
  42676. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42677. * @param maxCapacity defines the maximum capacity per leaf
  42678. * @param maxDepth defines the maximum depth of the octree
  42679. * @returns an octree of AbstractMesh
  42680. */
  42681. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42682. }
  42683. interface AbstractMesh {
  42684. /**
  42685. * @hidden
  42686. * Backing Field
  42687. */
  42688. _submeshesOctree: Octree<SubMesh>;
  42689. /**
  42690. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42691. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42692. * @param maxCapacity defines the maximum size of each block (64 by default)
  42693. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42694. * @returns the new octree
  42695. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42696. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42697. */
  42698. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42699. }
  42700. /**
  42701. * Defines the octree scene component responsible to manage any octrees
  42702. * in a given scene.
  42703. */
  42704. export class OctreeSceneComponent {
  42705. /**
  42706. * The component name help to identify the component in the list of scene components.
  42707. */
  42708. readonly name: string;
  42709. /**
  42710. * The scene the component belongs to.
  42711. */
  42712. scene: Scene;
  42713. /**
  42714. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42715. */
  42716. readonly checksIsEnabled: boolean;
  42717. /**
  42718. * Creates a new instance of the component for the given scene
  42719. * @param scene Defines the scene to register the component in
  42720. */
  42721. constructor(scene: Scene);
  42722. /**
  42723. * Registers the component in a given scene
  42724. */
  42725. register(): void;
  42726. /**
  42727. * Return the list of active meshes
  42728. * @returns the list of active meshes
  42729. */
  42730. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42731. /**
  42732. * Return the list of active sub meshes
  42733. * @param mesh The mesh to get the candidates sub meshes from
  42734. * @returns the list of active sub meshes
  42735. */
  42736. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42737. private _tempRay;
  42738. /**
  42739. * Return the list of sub meshes intersecting with a given local ray
  42740. * @param mesh defines the mesh to find the submesh for
  42741. * @param localRay defines the ray in local space
  42742. * @returns the list of intersecting sub meshes
  42743. */
  42744. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42745. /**
  42746. * Return the list of sub meshes colliding with a collider
  42747. * @param mesh defines the mesh to find the submesh for
  42748. * @param collider defines the collider to evaluate the collision against
  42749. * @returns the list of colliding sub meshes
  42750. */
  42751. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42752. /**
  42753. * Rebuilds the elements related to this component in case of
  42754. * context lost for instance.
  42755. */
  42756. rebuild(): void;
  42757. /**
  42758. * Disposes the component and the associated ressources.
  42759. */
  42760. dispose(): void;
  42761. }
  42762. }
  42763. declare module BABYLON {
  42764. /**
  42765. * Renders a layer on top of an existing scene
  42766. */
  42767. export class UtilityLayerRenderer implements IDisposable {
  42768. /** the original scene that will be rendered on top of */
  42769. originalScene: Scene;
  42770. private _pointerCaptures;
  42771. private _lastPointerEvents;
  42772. private static _DefaultUtilityLayer;
  42773. private static _DefaultKeepDepthUtilityLayer;
  42774. private _sharedGizmoLight;
  42775. private _renderCamera;
  42776. /**
  42777. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42778. * @returns the camera that is used when rendering the utility layer
  42779. */
  42780. getRenderCamera(): Nullable<Camera>;
  42781. /**
  42782. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42783. * @param cam the camera that should be used when rendering the utility layer
  42784. */
  42785. setRenderCamera(cam: Nullable<Camera>): void;
  42786. /**
  42787. * @hidden
  42788. * Light which used by gizmos to get light shading
  42789. */
  42790. _getSharedGizmoLight(): HemisphericLight;
  42791. /**
  42792. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42793. */
  42794. pickUtilitySceneFirst: boolean;
  42795. /**
  42796. * 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)
  42797. */
  42798. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42799. /**
  42800. * 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)
  42801. */
  42802. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42803. /**
  42804. * The scene that is rendered on top of the original scene
  42805. */
  42806. utilityLayerScene: Scene;
  42807. /**
  42808. * If the utility layer should automatically be rendered on top of existing scene
  42809. */
  42810. shouldRender: boolean;
  42811. /**
  42812. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42813. */
  42814. onlyCheckPointerDownEvents: boolean;
  42815. /**
  42816. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42817. */
  42818. processAllEvents: boolean;
  42819. /**
  42820. * Observable raised when the pointer move from the utility layer scene to the main scene
  42821. */
  42822. onPointerOutObservable: Observable<number>;
  42823. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42824. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42825. private _afterRenderObserver;
  42826. private _sceneDisposeObserver;
  42827. private _originalPointerObserver;
  42828. /**
  42829. * Instantiates a UtilityLayerRenderer
  42830. * @param originalScene the original scene that will be rendered on top of
  42831. * @param handleEvents boolean indicating if the utility layer should handle events
  42832. */
  42833. constructor(
  42834. /** the original scene that will be rendered on top of */
  42835. originalScene: Scene, handleEvents?: boolean);
  42836. private _notifyObservers;
  42837. /**
  42838. * Renders the utility layers scene on top of the original scene
  42839. */
  42840. render(): void;
  42841. /**
  42842. * Disposes of the renderer
  42843. */
  42844. dispose(): void;
  42845. private _updateCamera;
  42846. }
  42847. }
  42848. declare module BABYLON {
  42849. /**
  42850. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42851. */
  42852. export class Gizmo implements IDisposable {
  42853. /** The utility layer the gizmo will be added to */
  42854. gizmoLayer: UtilityLayerRenderer;
  42855. /**
  42856. * The root mesh of the gizmo
  42857. */
  42858. _rootMesh: Mesh;
  42859. private _attachedMesh;
  42860. /**
  42861. * Ratio for the scale of the gizmo (Default: 1)
  42862. */
  42863. scaleRatio: number;
  42864. /**
  42865. * If a custom mesh has been set (Default: false)
  42866. */
  42867. protected _customMeshSet: boolean;
  42868. /**
  42869. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42870. * * When set, interactions will be enabled
  42871. */
  42872. attachedMesh: Nullable<AbstractMesh>;
  42873. /**
  42874. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42875. * @param mesh The mesh to replace the default mesh of the gizmo
  42876. */
  42877. setCustomMesh(mesh: Mesh): void;
  42878. /**
  42879. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42880. */
  42881. updateGizmoRotationToMatchAttachedMesh: boolean;
  42882. /**
  42883. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42884. */
  42885. updateGizmoPositionToMatchAttachedMesh: boolean;
  42886. /**
  42887. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42888. */
  42889. updateScale: boolean;
  42890. protected _interactionsEnabled: boolean;
  42891. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42892. private _beforeRenderObserver;
  42893. private _tempVector;
  42894. /**
  42895. * Creates a gizmo
  42896. * @param gizmoLayer The utility layer the gizmo will be added to
  42897. */
  42898. constructor(
  42899. /** The utility layer the gizmo will be added to */
  42900. gizmoLayer?: UtilityLayerRenderer);
  42901. /**
  42902. * Updates the gizmo to match the attached mesh's position/rotation
  42903. */
  42904. protected _update(): void;
  42905. /**
  42906. * Disposes of the gizmo
  42907. */
  42908. dispose(): void;
  42909. }
  42910. }
  42911. declare module BABYLON {
  42912. /**
  42913. * Single plane drag gizmo
  42914. */
  42915. export class PlaneDragGizmo extends Gizmo {
  42916. /**
  42917. * Drag behavior responsible for the gizmos dragging interactions
  42918. */
  42919. dragBehavior: PointerDragBehavior;
  42920. private _pointerObserver;
  42921. /**
  42922. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42923. */
  42924. snapDistance: number;
  42925. /**
  42926. * Event that fires each time the gizmo snaps to a new location.
  42927. * * snapDistance is the the change in distance
  42928. */
  42929. onSnapObservable: Observable<{
  42930. snapDistance: number;
  42931. }>;
  42932. private _plane;
  42933. private _coloredMaterial;
  42934. private _hoverMaterial;
  42935. private _isEnabled;
  42936. private _parent;
  42937. /** @hidden */
  42938. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42939. /** @hidden */
  42940. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42941. /**
  42942. * Creates a PlaneDragGizmo
  42943. * @param gizmoLayer The utility layer the gizmo will be added to
  42944. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42945. * @param color The color of the gizmo
  42946. */
  42947. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42948. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42949. /**
  42950. * If the gizmo is enabled
  42951. */
  42952. isEnabled: boolean;
  42953. /**
  42954. * Disposes of the gizmo
  42955. */
  42956. dispose(): void;
  42957. }
  42958. }
  42959. declare module BABYLON {
  42960. /**
  42961. * Gizmo that enables dragging a mesh along 3 axis
  42962. */
  42963. export class PositionGizmo extends Gizmo {
  42964. /**
  42965. * Internal gizmo used for interactions on the x axis
  42966. */
  42967. xGizmo: AxisDragGizmo;
  42968. /**
  42969. * Internal gizmo used for interactions on the y axis
  42970. */
  42971. yGizmo: AxisDragGizmo;
  42972. /**
  42973. * Internal gizmo used for interactions on the z axis
  42974. */
  42975. zGizmo: AxisDragGizmo;
  42976. /**
  42977. * Internal gizmo used for interactions on the yz plane
  42978. */
  42979. xPlaneGizmo: PlaneDragGizmo;
  42980. /**
  42981. * Internal gizmo used for interactions on the xz plane
  42982. */
  42983. yPlaneGizmo: PlaneDragGizmo;
  42984. /**
  42985. * Internal gizmo used for interactions on the xy plane
  42986. */
  42987. zPlaneGizmo: PlaneDragGizmo;
  42988. /**
  42989. * private variables
  42990. */
  42991. private _meshAttached;
  42992. private _updateGizmoRotationToMatchAttachedMesh;
  42993. private _snapDistance;
  42994. private _scaleRatio;
  42995. /** Fires an event when any of it's sub gizmos are dragged */
  42996. onDragStartObservable: Observable<unknown>;
  42997. /** Fires an event when any of it's sub gizmos are released from dragging */
  42998. onDragEndObservable: Observable<unknown>;
  42999. /**
  43000. * If set to true, planar drag is enabled
  43001. */
  43002. private _planarGizmoEnabled;
  43003. attachedMesh: Nullable<AbstractMesh>;
  43004. /**
  43005. * Creates a PositionGizmo
  43006. * @param gizmoLayer The utility layer the gizmo will be added to
  43007. */
  43008. constructor(gizmoLayer?: UtilityLayerRenderer);
  43009. /**
  43010. * If the planar drag gizmo is enabled
  43011. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  43012. */
  43013. planarGizmoEnabled: boolean;
  43014. updateGizmoRotationToMatchAttachedMesh: boolean;
  43015. /**
  43016. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43017. */
  43018. snapDistance: number;
  43019. /**
  43020. * Ratio for the scale of the gizmo (Default: 1)
  43021. */
  43022. scaleRatio: number;
  43023. /**
  43024. * Disposes of the gizmo
  43025. */
  43026. dispose(): void;
  43027. /**
  43028. * CustomMeshes are not supported by this gizmo
  43029. * @param mesh The mesh to replace the default mesh of the gizmo
  43030. */
  43031. setCustomMesh(mesh: Mesh): void;
  43032. }
  43033. }
  43034. declare module BABYLON {
  43035. /**
  43036. * Single axis drag gizmo
  43037. */
  43038. export class AxisDragGizmo extends Gizmo {
  43039. /**
  43040. * Drag behavior responsible for the gizmos dragging interactions
  43041. */
  43042. dragBehavior: PointerDragBehavior;
  43043. private _pointerObserver;
  43044. /**
  43045. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43046. */
  43047. snapDistance: number;
  43048. /**
  43049. * Event that fires each time the gizmo snaps to a new location.
  43050. * * snapDistance is the the change in distance
  43051. */
  43052. onSnapObservable: Observable<{
  43053. snapDistance: number;
  43054. }>;
  43055. private _isEnabled;
  43056. private _parent;
  43057. private _arrow;
  43058. private _coloredMaterial;
  43059. private _hoverMaterial;
  43060. /** @hidden */
  43061. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43062. /** @hidden */
  43063. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43064. /**
  43065. * Creates an AxisDragGizmo
  43066. * @param gizmoLayer The utility layer the gizmo will be added to
  43067. * @param dragAxis The axis which the gizmo will be able to drag on
  43068. * @param color The color of the gizmo
  43069. */
  43070. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43071. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43072. /**
  43073. * If the gizmo is enabled
  43074. */
  43075. isEnabled: boolean;
  43076. /**
  43077. * Disposes of the gizmo
  43078. */
  43079. dispose(): void;
  43080. }
  43081. }
  43082. declare module BABYLON.Debug {
  43083. /**
  43084. * The Axes viewer will show 3 axes in a specific point in space
  43085. */
  43086. export class AxesViewer {
  43087. private _xAxis;
  43088. private _yAxis;
  43089. private _zAxis;
  43090. private _scaleLinesFactor;
  43091. private _instanced;
  43092. /**
  43093. * Gets the hosting scene
  43094. */
  43095. scene: Scene;
  43096. /**
  43097. * Gets or sets a number used to scale line length
  43098. */
  43099. scaleLines: number;
  43100. /** Gets the node hierarchy used to render x-axis */
  43101. readonly xAxis: TransformNode;
  43102. /** Gets the node hierarchy used to render y-axis */
  43103. readonly yAxis: TransformNode;
  43104. /** Gets the node hierarchy used to render z-axis */
  43105. readonly zAxis: TransformNode;
  43106. /**
  43107. * Creates a new AxesViewer
  43108. * @param scene defines the hosting scene
  43109. * @param scaleLines defines a number used to scale line length (1 by default)
  43110. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43111. * @param xAxis defines the node hierarchy used to render the x-axis
  43112. * @param yAxis defines the node hierarchy used to render the y-axis
  43113. * @param zAxis defines the node hierarchy used to render the z-axis
  43114. */
  43115. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  43116. /**
  43117. * Force the viewer to update
  43118. * @param position defines the position of the viewer
  43119. * @param xaxis defines the x axis of the viewer
  43120. * @param yaxis defines the y axis of the viewer
  43121. * @param zaxis defines the z axis of the viewer
  43122. */
  43123. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43124. /**
  43125. * Creates an instance of this axes viewer.
  43126. * @returns a new axes viewer with instanced meshes
  43127. */
  43128. createInstance(): AxesViewer;
  43129. /** Releases resources */
  43130. dispose(): void;
  43131. private static _SetRenderingGroupId;
  43132. }
  43133. }
  43134. declare module BABYLON.Debug {
  43135. /**
  43136. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43137. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43138. */
  43139. export class BoneAxesViewer extends AxesViewer {
  43140. /**
  43141. * Gets or sets the target mesh where to display the axes viewer
  43142. */
  43143. mesh: Nullable<Mesh>;
  43144. /**
  43145. * Gets or sets the target bone where to display the axes viewer
  43146. */
  43147. bone: Nullable<Bone>;
  43148. /** Gets current position */
  43149. pos: Vector3;
  43150. /** Gets direction of X axis */
  43151. xaxis: Vector3;
  43152. /** Gets direction of Y axis */
  43153. yaxis: Vector3;
  43154. /** Gets direction of Z axis */
  43155. zaxis: Vector3;
  43156. /**
  43157. * Creates a new BoneAxesViewer
  43158. * @param scene defines the hosting scene
  43159. * @param bone defines the target bone
  43160. * @param mesh defines the target mesh
  43161. * @param scaleLines defines a scaling factor for line length (1 by default)
  43162. */
  43163. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43164. /**
  43165. * Force the viewer to update
  43166. */
  43167. update(): void;
  43168. /** Releases resources */
  43169. dispose(): void;
  43170. }
  43171. }
  43172. declare module BABYLON {
  43173. /**
  43174. * Interface used to define scene explorer extensibility option
  43175. */
  43176. export interface IExplorerExtensibilityOption {
  43177. /**
  43178. * Define the option label
  43179. */
  43180. label: string;
  43181. /**
  43182. * Defines the action to execute on click
  43183. */
  43184. action: (entity: any) => void;
  43185. }
  43186. /**
  43187. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43188. */
  43189. export interface IExplorerExtensibilityGroup {
  43190. /**
  43191. * Defines a predicate to test if a given type mut be extended
  43192. */
  43193. predicate: (entity: any) => boolean;
  43194. /**
  43195. * Gets the list of options added to a type
  43196. */
  43197. entries: IExplorerExtensibilityOption[];
  43198. }
  43199. /**
  43200. * Interface used to define the options to use to create the Inspector
  43201. */
  43202. export interface IInspectorOptions {
  43203. /**
  43204. * Display in overlay mode (default: false)
  43205. */
  43206. overlay?: boolean;
  43207. /**
  43208. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43209. */
  43210. globalRoot?: HTMLElement;
  43211. /**
  43212. * Display the Scene explorer
  43213. */
  43214. showExplorer?: boolean;
  43215. /**
  43216. * Display the property inspector
  43217. */
  43218. showInspector?: boolean;
  43219. /**
  43220. * Display in embed mode (both panes on the right)
  43221. */
  43222. embedMode?: boolean;
  43223. /**
  43224. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43225. */
  43226. handleResize?: boolean;
  43227. /**
  43228. * Allow the panes to popup (default: true)
  43229. */
  43230. enablePopup?: boolean;
  43231. /**
  43232. * Allow the panes to be closed by users (default: true)
  43233. */
  43234. enableClose?: boolean;
  43235. /**
  43236. * Optional list of extensibility entries
  43237. */
  43238. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43239. /**
  43240. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43241. */
  43242. inspectorURL?: string;
  43243. }
  43244. interface Scene {
  43245. /**
  43246. * @hidden
  43247. * Backing field
  43248. */
  43249. _debugLayer: DebugLayer;
  43250. /**
  43251. * Gets the debug layer (aka Inspector) associated with the scene
  43252. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43253. */
  43254. debugLayer: DebugLayer;
  43255. }
  43256. /**
  43257. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43258. * what is happening in your scene
  43259. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43260. */
  43261. export class DebugLayer {
  43262. /**
  43263. * Define the url to get the inspector script from.
  43264. * By default it uses the babylonjs CDN.
  43265. * @ignoreNaming
  43266. */
  43267. static InspectorURL: string;
  43268. private _scene;
  43269. private BJSINSPECTOR;
  43270. private _onPropertyChangedObservable?;
  43271. /**
  43272. * Observable triggered when a property is changed through the inspector.
  43273. */
  43274. readonly onPropertyChangedObservable: any;
  43275. /**
  43276. * Instantiates a new debug layer.
  43277. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43278. * what is happening in your scene
  43279. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43280. * @param scene Defines the scene to inspect
  43281. */
  43282. constructor(scene: Scene);
  43283. /** Creates the inspector window. */
  43284. private _createInspector;
  43285. /**
  43286. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43287. * @param entity defines the entity to select
  43288. * @param lineContainerTitle defines the specific block to highlight
  43289. */
  43290. select(entity: any, lineContainerTitle?: string): void;
  43291. /** Get the inspector from bundle or global */
  43292. private _getGlobalInspector;
  43293. /**
  43294. * Get if the inspector is visible or not.
  43295. * @returns true if visible otherwise, false
  43296. */
  43297. isVisible(): boolean;
  43298. /**
  43299. * Hide the inspector and close its window.
  43300. */
  43301. hide(): void;
  43302. /**
  43303. * Launch the debugLayer.
  43304. * @param config Define the configuration of the inspector
  43305. * @return a promise fulfilled when the debug layer is visible
  43306. */
  43307. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43308. }
  43309. }
  43310. declare module BABYLON {
  43311. /**
  43312. * Class containing static functions to help procedurally build meshes
  43313. */
  43314. export class BoxBuilder {
  43315. /**
  43316. * Creates a box mesh
  43317. * * The parameter `size` sets the size (float) of each box side (default 1)
  43318. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43319. * * 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)
  43320. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43322. * * 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
  43323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43324. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43325. * @param name defines the name of the mesh
  43326. * @param options defines the options used to create the mesh
  43327. * @param scene defines the hosting scene
  43328. * @returns the box mesh
  43329. */
  43330. static CreateBox(name: string, options: {
  43331. size?: number;
  43332. width?: number;
  43333. height?: number;
  43334. depth?: number;
  43335. faceUV?: Vector4[];
  43336. faceColors?: Color4[];
  43337. sideOrientation?: number;
  43338. frontUVs?: Vector4;
  43339. backUVs?: Vector4;
  43340. wrap?: boolean;
  43341. topBaseAt?: number;
  43342. bottomBaseAt?: number;
  43343. updatable?: boolean;
  43344. }, scene?: Nullable<Scene>): Mesh;
  43345. }
  43346. }
  43347. declare module BABYLON {
  43348. /**
  43349. * Class containing static functions to help procedurally build meshes
  43350. */
  43351. export class SphereBuilder {
  43352. /**
  43353. * Creates a sphere mesh
  43354. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43355. * * 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`)
  43356. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43357. * * 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
  43358. * * 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)
  43359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43360. * * 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
  43361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43362. * @param name defines the name of the mesh
  43363. * @param options defines the options used to create the mesh
  43364. * @param scene defines the hosting scene
  43365. * @returns the sphere mesh
  43366. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43367. */
  43368. static CreateSphere(name: string, options: {
  43369. segments?: number;
  43370. diameter?: number;
  43371. diameterX?: number;
  43372. diameterY?: number;
  43373. diameterZ?: number;
  43374. arc?: number;
  43375. slice?: number;
  43376. sideOrientation?: number;
  43377. frontUVs?: Vector4;
  43378. backUVs?: Vector4;
  43379. updatable?: boolean;
  43380. }, scene?: Nullable<Scene>): Mesh;
  43381. }
  43382. }
  43383. declare module BABYLON.Debug {
  43384. /**
  43385. * Used to show the physics impostor around the specific mesh
  43386. */
  43387. export class PhysicsViewer {
  43388. /** @hidden */
  43389. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43390. /** @hidden */
  43391. protected _meshes: Array<Nullable<AbstractMesh>>;
  43392. /** @hidden */
  43393. protected _scene: Nullable<Scene>;
  43394. /** @hidden */
  43395. protected _numMeshes: number;
  43396. /** @hidden */
  43397. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43398. private _renderFunction;
  43399. private _utilityLayer;
  43400. private _debugBoxMesh;
  43401. private _debugSphereMesh;
  43402. private _debugCylinderMesh;
  43403. private _debugMaterial;
  43404. private _debugMeshMeshes;
  43405. /**
  43406. * Creates a new PhysicsViewer
  43407. * @param scene defines the hosting scene
  43408. */
  43409. constructor(scene: Scene);
  43410. /** @hidden */
  43411. protected _updateDebugMeshes(): void;
  43412. /**
  43413. * Renders a specified physic impostor
  43414. * @param impostor defines the impostor to render
  43415. * @param targetMesh defines the mesh represented by the impostor
  43416. * @returns the new debug mesh used to render the impostor
  43417. */
  43418. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43419. /**
  43420. * Hides a specified physic impostor
  43421. * @param impostor defines the impostor to hide
  43422. */
  43423. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43424. private _getDebugMaterial;
  43425. private _getDebugBoxMesh;
  43426. private _getDebugSphereMesh;
  43427. private _getDebugCylinderMesh;
  43428. private _getDebugMeshMesh;
  43429. private _getDebugMesh;
  43430. /** Releases all resources */
  43431. dispose(): void;
  43432. }
  43433. }
  43434. declare module BABYLON {
  43435. /**
  43436. * Class containing static functions to help procedurally build meshes
  43437. */
  43438. export class LinesBuilder {
  43439. /**
  43440. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43441. * * 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
  43442. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43443. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43444. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43445. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43446. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43447. * * 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
  43448. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43450. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43451. * @param name defines the name of the new line system
  43452. * @param options defines the options used to create the line system
  43453. * @param scene defines the hosting scene
  43454. * @returns a new line system mesh
  43455. */
  43456. static CreateLineSystem(name: string, options: {
  43457. lines: Vector3[][];
  43458. updatable?: boolean;
  43459. instance?: Nullable<LinesMesh>;
  43460. colors?: Nullable<Color4[][]>;
  43461. useVertexAlpha?: boolean;
  43462. }, scene: Nullable<Scene>): LinesMesh;
  43463. /**
  43464. * Creates a line mesh
  43465. * 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
  43466. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43467. * * The parameter `points` is an array successive Vector3
  43468. * * 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
  43469. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43470. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43471. * * When updating an instance, remember that only point positions can change, not the number of points
  43472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43473. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43474. * @param name defines the name of the new line system
  43475. * @param options defines the options used to create the line system
  43476. * @param scene defines the hosting scene
  43477. * @returns a new line mesh
  43478. */
  43479. static CreateLines(name: string, options: {
  43480. points: Vector3[];
  43481. updatable?: boolean;
  43482. instance?: Nullable<LinesMesh>;
  43483. colors?: Color4[];
  43484. useVertexAlpha?: boolean;
  43485. }, scene?: Nullable<Scene>): LinesMesh;
  43486. /**
  43487. * Creates a dashed line mesh
  43488. * * 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
  43489. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43490. * * The parameter `points` is an array successive Vector3
  43491. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43492. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43493. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43494. * * 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
  43495. * * When updating an instance, remember that only point positions can change, not the number of points
  43496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43497. * @param name defines the name of the mesh
  43498. * @param options defines the options used to create the mesh
  43499. * @param scene defines the hosting scene
  43500. * @returns the dashed line mesh
  43501. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43502. */
  43503. static CreateDashedLines(name: string, options: {
  43504. points: Vector3[];
  43505. dashSize?: number;
  43506. gapSize?: number;
  43507. dashNb?: number;
  43508. updatable?: boolean;
  43509. instance?: LinesMesh;
  43510. }, scene?: Nullable<Scene>): LinesMesh;
  43511. }
  43512. }
  43513. declare module BABYLON {
  43514. /**
  43515. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43516. * in order to better appreciate the issue one might have.
  43517. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43518. */
  43519. export class RayHelper {
  43520. /**
  43521. * Defines the ray we are currently tryin to visualize.
  43522. */
  43523. ray: Nullable<Ray>;
  43524. private _renderPoints;
  43525. private _renderLine;
  43526. private _renderFunction;
  43527. private _scene;
  43528. private _updateToMeshFunction;
  43529. private _attachedToMesh;
  43530. private _meshSpaceDirection;
  43531. private _meshSpaceOrigin;
  43532. /**
  43533. * Helper function to create a colored helper in a scene in one line.
  43534. * @param ray Defines the ray we are currently tryin to visualize
  43535. * @param scene Defines the scene the ray is used in
  43536. * @param color Defines the color we want to see the ray in
  43537. * @returns The newly created ray helper.
  43538. */
  43539. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43540. /**
  43541. * Instantiate a new ray helper.
  43542. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43543. * in order to better appreciate the issue one might have.
  43544. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43545. * @param ray Defines the ray we are currently tryin to visualize
  43546. */
  43547. constructor(ray: Ray);
  43548. /**
  43549. * Shows the ray we are willing to debug.
  43550. * @param scene Defines the scene the ray needs to be rendered in
  43551. * @param color Defines the color the ray needs to be rendered in
  43552. */
  43553. show(scene: Scene, color?: Color3): void;
  43554. /**
  43555. * Hides the ray we are debugging.
  43556. */
  43557. hide(): void;
  43558. private _render;
  43559. /**
  43560. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43561. * @param mesh Defines the mesh we want the helper attached to
  43562. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43563. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43564. * @param length Defines the length of the ray
  43565. */
  43566. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43567. /**
  43568. * Detach the ray helper from the mesh it has previously been attached to.
  43569. */
  43570. detachFromMesh(): void;
  43571. private _updateToMesh;
  43572. /**
  43573. * Dispose the helper and release its associated resources.
  43574. */
  43575. dispose(): void;
  43576. }
  43577. }
  43578. declare module BABYLON.Debug {
  43579. /**
  43580. * Class used to render a debug view of a given skeleton
  43581. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43582. */
  43583. export class SkeletonViewer {
  43584. /** defines the skeleton to render */
  43585. skeleton: Skeleton;
  43586. /** defines the mesh attached to the skeleton */
  43587. mesh: AbstractMesh;
  43588. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43589. autoUpdateBonesMatrices: boolean;
  43590. /** defines the rendering group id to use with the viewer */
  43591. renderingGroupId: number;
  43592. /** Gets or sets the color used to render the skeleton */
  43593. color: Color3;
  43594. private _scene;
  43595. private _debugLines;
  43596. private _debugMesh;
  43597. private _isEnabled;
  43598. private _renderFunction;
  43599. private _utilityLayer;
  43600. /**
  43601. * Returns the mesh used to render the bones
  43602. */
  43603. readonly debugMesh: Nullable<LinesMesh>;
  43604. /**
  43605. * Creates a new SkeletonViewer
  43606. * @param skeleton defines the skeleton to render
  43607. * @param mesh defines the mesh attached to the skeleton
  43608. * @param scene defines the hosting scene
  43609. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43610. * @param renderingGroupId defines the rendering group id to use with the viewer
  43611. */
  43612. constructor(
  43613. /** defines the skeleton to render */
  43614. skeleton: Skeleton,
  43615. /** defines the mesh attached to the skeleton */
  43616. mesh: AbstractMesh, scene: Scene,
  43617. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43618. autoUpdateBonesMatrices?: boolean,
  43619. /** defines the rendering group id to use with the viewer */
  43620. renderingGroupId?: number);
  43621. /** Gets or sets a boolean indicating if the viewer is enabled */
  43622. isEnabled: boolean;
  43623. private _getBonePosition;
  43624. private _getLinesForBonesWithLength;
  43625. private _getLinesForBonesNoLength;
  43626. /** Update the viewer to sync with current skeleton state */
  43627. update(): void;
  43628. /** Release associated resources */
  43629. dispose(): void;
  43630. }
  43631. }
  43632. declare module BABYLON {
  43633. /**
  43634. * Options to create the null engine
  43635. */
  43636. export class NullEngineOptions {
  43637. /**
  43638. * Render width (Default: 512)
  43639. */
  43640. renderWidth: number;
  43641. /**
  43642. * Render height (Default: 256)
  43643. */
  43644. renderHeight: number;
  43645. /**
  43646. * Texture size (Default: 512)
  43647. */
  43648. textureSize: number;
  43649. /**
  43650. * If delta time between frames should be constant
  43651. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43652. */
  43653. deterministicLockstep: boolean;
  43654. /**
  43655. * Maximum about of steps between frames (Default: 4)
  43656. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43657. */
  43658. lockstepMaxSteps: number;
  43659. }
  43660. /**
  43661. * The null engine class provides support for headless version of babylon.js.
  43662. * This can be used in server side scenario or for testing purposes
  43663. */
  43664. export class NullEngine extends Engine {
  43665. private _options;
  43666. /**
  43667. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43668. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43669. * @returns true if engine is in deterministic lock step mode
  43670. */
  43671. isDeterministicLockStep(): boolean;
  43672. /**
  43673. * Gets the max steps when engine is running in deterministic lock step
  43674. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43675. * @returns the max steps
  43676. */
  43677. getLockstepMaxSteps(): number;
  43678. /**
  43679. * Gets the current hardware scaling level.
  43680. * By default the hardware scaling level is computed from the window device ratio.
  43681. * 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.
  43682. * @returns a number indicating the current hardware scaling level
  43683. */
  43684. getHardwareScalingLevel(): number;
  43685. constructor(options?: NullEngineOptions);
  43686. /**
  43687. * Creates a vertex buffer
  43688. * @param vertices the data for the vertex buffer
  43689. * @returns the new WebGL static buffer
  43690. */
  43691. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43692. /**
  43693. * Creates a new index buffer
  43694. * @param indices defines the content of the index buffer
  43695. * @param updatable defines if the index buffer must be updatable
  43696. * @returns a new webGL buffer
  43697. */
  43698. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43699. /**
  43700. * Clear the current render buffer or the current render target (if any is set up)
  43701. * @param color defines the color to use
  43702. * @param backBuffer defines if the back buffer must be cleared
  43703. * @param depth defines if the depth buffer must be cleared
  43704. * @param stencil defines if the stencil buffer must be cleared
  43705. */
  43706. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43707. /**
  43708. * Gets the current render width
  43709. * @param useScreen defines if screen size must be used (or the current render target if any)
  43710. * @returns a number defining the current render width
  43711. */
  43712. getRenderWidth(useScreen?: boolean): number;
  43713. /**
  43714. * Gets the current render height
  43715. * @param useScreen defines if screen size must be used (or the current render target if any)
  43716. * @returns a number defining the current render height
  43717. */
  43718. getRenderHeight(useScreen?: boolean): number;
  43719. /**
  43720. * Set the WebGL's viewport
  43721. * @param viewport defines the viewport element to be used
  43722. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  43723. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  43724. */
  43725. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43726. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43727. /**
  43728. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  43729. * @param pipelineContext defines the pipeline context to use
  43730. * @param uniformsNames defines the list of uniform names
  43731. * @returns an array of webGL uniform locations
  43732. */
  43733. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43734. /**
  43735. * Gets the lsit of active attributes for a given webGL program
  43736. * @param pipelineContext defines the pipeline context to use
  43737. * @param attributesNames defines the list of attribute names to get
  43738. * @returns an array of indices indicating the offset of each attribute
  43739. */
  43740. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43741. /**
  43742. * Binds an effect to the webGL context
  43743. * @param effect defines the effect to bind
  43744. */
  43745. bindSamplers(effect: Effect): void;
  43746. /**
  43747. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  43748. * @param effect defines the effect to activate
  43749. */
  43750. enableEffect(effect: Effect): void;
  43751. /**
  43752. * Set various states to the webGL context
  43753. * @param culling defines backface culling state
  43754. * @param zOffset defines the value to apply to zOffset (0 by default)
  43755. * @param force defines if states must be applied even if cache is up to date
  43756. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43757. */
  43758. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43759. /**
  43760. * Set the value of an uniform to an array of int32
  43761. * @param uniform defines the webGL uniform location where to store the value
  43762. * @param array defines the array of int32 to store
  43763. */
  43764. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43765. /**
  43766. * Set the value of an uniform to an array of int32 (stored as vec2)
  43767. * @param uniform defines the webGL uniform location where to store the value
  43768. * @param array defines the array of int32 to store
  43769. */
  43770. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43771. /**
  43772. * Set the value of an uniform to an array of int32 (stored as vec3)
  43773. * @param uniform defines the webGL uniform location where to store the value
  43774. * @param array defines the array of int32 to store
  43775. */
  43776. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43777. /**
  43778. * Set the value of an uniform to an array of int32 (stored as vec4)
  43779. * @param uniform defines the webGL uniform location where to store the value
  43780. * @param array defines the array of int32 to store
  43781. */
  43782. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43783. /**
  43784. * Set the value of an uniform to an array of float32
  43785. * @param uniform defines the webGL uniform location where to store the value
  43786. * @param array defines the array of float32 to store
  43787. */
  43788. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43789. /**
  43790. * Set the value of an uniform to an array of float32 (stored as vec2)
  43791. * @param uniform defines the webGL uniform location where to store the value
  43792. * @param array defines the array of float32 to store
  43793. */
  43794. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43795. /**
  43796. * Set the value of an uniform to an array of float32 (stored as vec3)
  43797. * @param uniform defines the webGL uniform location where to store the value
  43798. * @param array defines the array of float32 to store
  43799. */
  43800. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43801. /**
  43802. * Set the value of an uniform to an array of float32 (stored as vec4)
  43803. * @param uniform defines the webGL uniform location where to store the value
  43804. * @param array defines the array of float32 to store
  43805. */
  43806. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43807. /**
  43808. * Set the value of an uniform to an array of number
  43809. * @param uniform defines the webGL uniform location where to store the value
  43810. * @param array defines the array of number to store
  43811. */
  43812. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43813. /**
  43814. * Set the value of an uniform to an array of number (stored as vec2)
  43815. * @param uniform defines the webGL uniform location where to store the value
  43816. * @param array defines the array of number to store
  43817. */
  43818. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43819. /**
  43820. * Set the value of an uniform to an array of number (stored as vec3)
  43821. * @param uniform defines the webGL uniform location where to store the value
  43822. * @param array defines the array of number to store
  43823. */
  43824. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43825. /**
  43826. * Set the value of an uniform to an array of number (stored as vec4)
  43827. * @param uniform defines the webGL uniform location where to store the value
  43828. * @param array defines the array of number to store
  43829. */
  43830. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43831. /**
  43832. * Set the value of an uniform to an array of float32 (stored as matrices)
  43833. * @param uniform defines the webGL uniform location where to store the value
  43834. * @param matrices defines the array of float32 to store
  43835. */
  43836. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43837. /**
  43838. * Set the value of an uniform to a matrix (3x3)
  43839. * @param uniform defines the webGL uniform location where to store the value
  43840. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  43841. */
  43842. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43843. /**
  43844. * Set the value of an uniform to a matrix (2x2)
  43845. * @param uniform defines the webGL uniform location where to store the value
  43846. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  43847. */
  43848. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43849. /**
  43850. * Set the value of an uniform to a number (float)
  43851. * @param uniform defines the webGL uniform location where to store the value
  43852. * @param value defines the float number to store
  43853. */
  43854. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43855. /**
  43856. * Set the value of an uniform to a vec2
  43857. * @param uniform defines the webGL uniform location where to store the value
  43858. * @param x defines the 1st component of the value
  43859. * @param y defines the 2nd component of the value
  43860. */
  43861. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43862. /**
  43863. * Set the value of an uniform to a vec3
  43864. * @param uniform defines the webGL uniform location where to store the value
  43865. * @param x defines the 1st component of the value
  43866. * @param y defines the 2nd component of the value
  43867. * @param z defines the 3rd component of the value
  43868. */
  43869. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43870. /**
  43871. * Set the value of an uniform to a boolean
  43872. * @param uniform defines the webGL uniform location where to store the value
  43873. * @param bool defines the boolean to store
  43874. */
  43875. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43876. /**
  43877. * Set the value of an uniform to a vec4
  43878. * @param uniform defines the webGL uniform location where to store the value
  43879. * @param x defines the 1st component of the value
  43880. * @param y defines the 2nd component of the value
  43881. * @param z defines the 3rd component of the value
  43882. * @param w defines the 4th component of the value
  43883. */
  43884. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43885. /**
  43886. * Sets the current alpha mode
  43887. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  43888. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43889. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43890. */
  43891. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43892. /**
  43893. * Bind webGl buffers directly to the webGL context
  43894. * @param vertexBuffers defines the vertex buffer to bind
  43895. * @param indexBuffer defines the index buffer to bind
  43896. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  43897. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  43898. * @param effect defines the effect associated with the vertex buffer
  43899. */
  43900. bindBuffers(vertexBuffers: {
  43901. [key: string]: VertexBuffer;
  43902. }, indexBuffer: DataBuffer, effect: Effect): void;
  43903. /**
  43904. * Force the entire cache to be cleared
  43905. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  43906. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  43907. */
  43908. wipeCaches(bruteForce?: boolean): void;
  43909. /**
  43910. * Send a draw order
  43911. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  43912. * @param indexStart defines the starting index
  43913. * @param indexCount defines the number of index to draw
  43914. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43915. */
  43916. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43917. /**
  43918. * Draw a list of indexed primitives
  43919. * @param fillMode defines the primitive to use
  43920. * @param indexStart defines the starting index
  43921. * @param indexCount defines the number of index to draw
  43922. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43923. */
  43924. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43925. /**
  43926. * Draw a list of unindexed primitives
  43927. * @param fillMode defines the primitive to use
  43928. * @param verticesStart defines the index of first vertex to draw
  43929. * @param verticesCount defines the count of vertices to draw
  43930. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43931. */
  43932. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43933. /** @hidden */
  43934. _createTexture(): WebGLTexture;
  43935. /** @hidden */
  43936. _releaseTexture(texture: InternalTexture): void;
  43937. /**
  43938. * Usually called from Texture.ts.
  43939. * Passed information to create a WebGLTexture
  43940. * @param urlArg defines a value which contains one of the following:
  43941. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43942. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43943. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43944. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43945. * @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)
  43946. * @param scene needed for loading to the correct scene
  43947. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  43948. * @param onLoad optional callback to be called upon successful completion
  43949. * @param onError optional callback to be called upon failure
  43950. * @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
  43951. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43952. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43953. * @param forcedExtension defines the extension to use to pick the right loader
  43954. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  43955. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43956. */
  43957. 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;
  43958. /**
  43959. * Creates a new render target texture
  43960. * @param size defines the size of the texture
  43961. * @param options defines the options used to create the texture
  43962. * @returns a new render target texture stored in an InternalTexture
  43963. */
  43964. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43965. /**
  43966. * Update the sampling mode of a given texture
  43967. * @param samplingMode defines the required sampling mode
  43968. * @param texture defines the texture to update
  43969. */
  43970. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43971. /**
  43972. * Binds the frame buffer to the specified texture.
  43973. * @param texture The texture to render to or null for the default canvas
  43974. * @param faceIndex The face of the texture to render to in case of cube texture
  43975. * @param requiredWidth The width of the target to render to
  43976. * @param requiredHeight The height of the target to render to
  43977. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  43978. * @param depthStencilTexture The depth stencil texture to use to render
  43979. * @param lodLevel defines le lod level to bind to the frame buffer
  43980. */
  43981. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43982. /**
  43983. * Unbind the current render target texture from the webGL context
  43984. * @param texture defines the render target texture to unbind
  43985. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43986. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43987. */
  43988. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43989. /**
  43990. * Creates a dynamic vertex buffer
  43991. * @param vertices the data for the dynamic vertex buffer
  43992. * @returns the new WebGL dynamic buffer
  43993. */
  43994. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43995. /**
  43996. * Update the content of a dynamic texture
  43997. * @param texture defines the texture to update
  43998. * @param canvas defines the canvas containing the source
  43999. * @param invertY defines if data must be stored with Y axis inverted
  44000. * @param premulAlpha defines if alpha is stored as premultiplied
  44001. * @param format defines the format of the data
  44002. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  44003. */
  44004. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44005. /**
  44006. * Gets a boolean indicating if all created effects are ready
  44007. * @returns true if all effects are ready
  44008. */
  44009. areAllEffectsReady(): boolean;
  44010. /**
  44011. * @hidden
  44012. * Get the current error code of the webGL context
  44013. * @returns the error code
  44014. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  44015. */
  44016. getError(): number;
  44017. /** @hidden */
  44018. _getUnpackAlignement(): number;
  44019. /** @hidden */
  44020. _unpackFlipY(value: boolean): void;
  44021. /**
  44022. * Update a dynamic index buffer
  44023. * @param indexBuffer defines the target index buffer
  44024. * @param indices defines the data to update
  44025. * @param offset defines the offset in the target index buffer where update should start
  44026. */
  44027. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44028. /**
  44029. * Updates a dynamic vertex buffer.
  44030. * @param vertexBuffer the vertex buffer to update
  44031. * @param vertices the data used to update the vertex buffer
  44032. * @param byteOffset the byte offset of the data (optional)
  44033. * @param byteLength the byte length of the data (optional)
  44034. */
  44035. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44036. /** @hidden */
  44037. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44038. /** @hidden */
  44039. _bindTexture(channel: number, texture: InternalTexture): void;
  44040. protected _deleteBuffer(buffer: WebGLBuffer): void;
  44041. /**
  44042. * 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
  44043. */
  44044. releaseEffects(): void;
  44045. displayLoadingUI(): void;
  44046. hideLoadingUI(): void;
  44047. /** @hidden */
  44048. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44049. /** @hidden */
  44050. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44051. /** @hidden */
  44052. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44053. /** @hidden */
  44054. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44055. }
  44056. }
  44057. declare module BABYLON {
  44058. /** @hidden */
  44059. export class _OcclusionDataStorage {
  44060. /** @hidden */
  44061. occlusionInternalRetryCounter: number;
  44062. /** @hidden */
  44063. isOcclusionQueryInProgress: boolean;
  44064. /** @hidden */
  44065. isOccluded: boolean;
  44066. /** @hidden */
  44067. occlusionRetryCount: number;
  44068. /** @hidden */
  44069. occlusionType: number;
  44070. /** @hidden */
  44071. occlusionQueryAlgorithmType: number;
  44072. }
  44073. interface Engine {
  44074. /**
  44075. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44076. * @return the new query
  44077. */
  44078. createQuery(): WebGLQuery;
  44079. /**
  44080. * Delete and release a webGL query
  44081. * @param query defines the query to delete
  44082. * @return the current engine
  44083. */
  44084. deleteQuery(query: WebGLQuery): Engine;
  44085. /**
  44086. * Check if a given query has resolved and got its value
  44087. * @param query defines the query to check
  44088. * @returns true if the query got its value
  44089. */
  44090. isQueryResultAvailable(query: WebGLQuery): boolean;
  44091. /**
  44092. * Gets the value of a given query
  44093. * @param query defines the query to check
  44094. * @returns the value of the query
  44095. */
  44096. getQueryResult(query: WebGLQuery): number;
  44097. /**
  44098. * Initiates an occlusion query
  44099. * @param algorithmType defines the algorithm to use
  44100. * @param query defines the query to use
  44101. * @returns the current engine
  44102. * @see http://doc.babylonjs.com/features/occlusionquery
  44103. */
  44104. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44105. /**
  44106. * Ends an occlusion query
  44107. * @see http://doc.babylonjs.com/features/occlusionquery
  44108. * @param algorithmType defines the algorithm to use
  44109. * @returns the current engine
  44110. */
  44111. endOcclusionQuery(algorithmType: number): Engine;
  44112. /**
  44113. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44114. * Please note that only one query can be issued at a time
  44115. * @returns a time token used to track the time span
  44116. */
  44117. startTimeQuery(): Nullable<_TimeToken>;
  44118. /**
  44119. * Ends a time query
  44120. * @param token defines the token used to measure the time span
  44121. * @returns the time spent (in ns)
  44122. */
  44123. endTimeQuery(token: _TimeToken): int;
  44124. /** @hidden */
  44125. _currentNonTimestampToken: Nullable<_TimeToken>;
  44126. /** @hidden */
  44127. _createTimeQuery(): WebGLQuery;
  44128. /** @hidden */
  44129. _deleteTimeQuery(query: WebGLQuery): void;
  44130. /** @hidden */
  44131. _getGlAlgorithmType(algorithmType: number): number;
  44132. /** @hidden */
  44133. _getTimeQueryResult(query: WebGLQuery): any;
  44134. /** @hidden */
  44135. _getTimeQueryAvailability(query: WebGLQuery): any;
  44136. }
  44137. interface AbstractMesh {
  44138. /**
  44139. * Backing filed
  44140. * @hidden
  44141. */
  44142. __occlusionDataStorage: _OcclusionDataStorage;
  44143. /**
  44144. * Access property
  44145. * @hidden
  44146. */
  44147. _occlusionDataStorage: _OcclusionDataStorage;
  44148. /**
  44149. * 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.
  44150. * The default value is -1 which means don't break the query and wait till the result
  44151. * @see http://doc.babylonjs.com/features/occlusionquery
  44152. */
  44153. occlusionRetryCount: number;
  44154. /**
  44155. * 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:
  44156. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44157. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44158. * * 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.
  44159. * @see http://doc.babylonjs.com/features/occlusionquery
  44160. */
  44161. occlusionType: number;
  44162. /**
  44163. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44164. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44165. * * 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.
  44166. * @see http://doc.babylonjs.com/features/occlusionquery
  44167. */
  44168. occlusionQueryAlgorithmType: number;
  44169. /**
  44170. * 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
  44171. * @see http://doc.babylonjs.com/features/occlusionquery
  44172. */
  44173. isOccluded: boolean;
  44174. /**
  44175. * Flag to check the progress status of the query
  44176. * @see http://doc.babylonjs.com/features/occlusionquery
  44177. */
  44178. isOcclusionQueryInProgress: boolean;
  44179. }
  44180. }
  44181. declare module BABYLON {
  44182. /** @hidden */
  44183. export var _forceTransformFeedbackToBundle: boolean;
  44184. interface Engine {
  44185. /**
  44186. * Creates a webGL transform feedback object
  44187. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44188. * @returns the webGL transform feedback object
  44189. */
  44190. createTransformFeedback(): WebGLTransformFeedback;
  44191. /**
  44192. * Delete a webGL transform feedback object
  44193. * @param value defines the webGL transform feedback object to delete
  44194. */
  44195. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44196. /**
  44197. * Bind a webGL transform feedback object to the webgl context
  44198. * @param value defines the webGL transform feedback object to bind
  44199. */
  44200. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44201. /**
  44202. * Begins a transform feedback operation
  44203. * @param usePoints defines if points or triangles must be used
  44204. */
  44205. beginTransformFeedback(usePoints: boolean): void;
  44206. /**
  44207. * Ends a transform feedback operation
  44208. */
  44209. endTransformFeedback(): void;
  44210. /**
  44211. * Specify the varyings to use with transform feedback
  44212. * @param program defines the associated webGL program
  44213. * @param value defines the list of strings representing the varying names
  44214. */
  44215. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44216. /**
  44217. * Bind a webGL buffer for a transform feedback operation
  44218. * @param value defines the webGL buffer to bind
  44219. */
  44220. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44221. }
  44222. }
  44223. declare module BABYLON {
  44224. /**
  44225. * Creation options of the multi render target texture.
  44226. */
  44227. export interface IMultiRenderTargetOptions {
  44228. /**
  44229. * Define if the texture needs to create mip maps after render.
  44230. */
  44231. generateMipMaps?: boolean;
  44232. /**
  44233. * Define the types of all the draw buffers we want to create
  44234. */
  44235. types?: number[];
  44236. /**
  44237. * Define the sampling modes of all the draw buffers we want to create
  44238. */
  44239. samplingModes?: number[];
  44240. /**
  44241. * Define if a depth buffer is required
  44242. */
  44243. generateDepthBuffer?: boolean;
  44244. /**
  44245. * Define if a stencil buffer is required
  44246. */
  44247. generateStencilBuffer?: boolean;
  44248. /**
  44249. * Define if a depth texture is required instead of a depth buffer
  44250. */
  44251. generateDepthTexture?: boolean;
  44252. /**
  44253. * Define the number of desired draw buffers
  44254. */
  44255. textureCount?: number;
  44256. /**
  44257. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44258. */
  44259. doNotChangeAspectRatio?: boolean;
  44260. /**
  44261. * Define the default type of the buffers we are creating
  44262. */
  44263. defaultType?: number;
  44264. }
  44265. /**
  44266. * A multi render target, like a render target provides the ability to render to a texture.
  44267. * Unlike the render target, it can render to several draw buffers in one draw.
  44268. * This is specially interesting in deferred rendering or for any effects requiring more than
  44269. * just one color from a single pass.
  44270. */
  44271. export class MultiRenderTarget extends RenderTargetTexture {
  44272. private _internalTextures;
  44273. private _textures;
  44274. private _multiRenderTargetOptions;
  44275. /**
  44276. * Get if draw buffers are currently supported by the used hardware and browser.
  44277. */
  44278. readonly isSupported: boolean;
  44279. /**
  44280. * Get the list of textures generated by the multi render target.
  44281. */
  44282. readonly textures: Texture[];
  44283. /**
  44284. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44285. */
  44286. readonly depthTexture: Texture;
  44287. /**
  44288. * Set the wrapping mode on U of all the textures we are rendering to.
  44289. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44290. */
  44291. wrapU: number;
  44292. /**
  44293. * Set the wrapping mode on V of all the textures we are rendering to.
  44294. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44295. */
  44296. wrapV: number;
  44297. /**
  44298. * Instantiate a new multi render target texture.
  44299. * A multi render target, like a render target provides the ability to render to a texture.
  44300. * Unlike the render target, it can render to several draw buffers in one draw.
  44301. * This is specially interesting in deferred rendering or for any effects requiring more than
  44302. * just one color from a single pass.
  44303. * @param name Define the name of the texture
  44304. * @param size Define the size of the buffers to render to
  44305. * @param count Define the number of target we are rendering into
  44306. * @param scene Define the scene the texture belongs to
  44307. * @param options Define the options used to create the multi render target
  44308. */
  44309. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44310. /** @hidden */
  44311. _rebuild(): void;
  44312. private _createInternalTextures;
  44313. private _createTextures;
  44314. /**
  44315. * Define the number of samples used if MSAA is enabled.
  44316. */
  44317. samples: number;
  44318. /**
  44319. * Resize all the textures in the multi render target.
  44320. * Be carrefull as it will recreate all the data in the new texture.
  44321. * @param size Define the new size
  44322. */
  44323. resize(size: any): void;
  44324. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44325. /**
  44326. * Dispose the render targets and their associated resources
  44327. */
  44328. dispose(): void;
  44329. /**
  44330. * Release all the underlying texture used as draw buffers.
  44331. */
  44332. releaseInternalTextures(): void;
  44333. }
  44334. }
  44335. declare module BABYLON {
  44336. interface ThinEngine {
  44337. /**
  44338. * Unbind a list of render target textures from the webGL context
  44339. * This is used only when drawBuffer extension or webGL2 are active
  44340. * @param textures defines the render target textures to unbind
  44341. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44342. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44343. */
  44344. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44345. /**
  44346. * Create a multi render target texture
  44347. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44348. * @param size defines the size of the texture
  44349. * @param options defines the creation options
  44350. * @returns the cube texture as an InternalTexture
  44351. */
  44352. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44353. /**
  44354. * Update the sample count for a given multiple render target texture
  44355. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44356. * @param textures defines the textures to update
  44357. * @param samples defines the sample count to set
  44358. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44359. */
  44360. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44361. }
  44362. }
  44363. declare module BABYLON {
  44364. /** @hidden */
  44365. export var rgbdEncodePixelShader: {
  44366. name: string;
  44367. shader: string;
  44368. };
  44369. }
  44370. declare module BABYLON {
  44371. /** @hidden */
  44372. export var rgbdDecodePixelShader: {
  44373. name: string;
  44374. shader: string;
  44375. };
  44376. }
  44377. declare module BABYLON {
  44378. /**
  44379. * Raw texture data and descriptor sufficient for WebGL texture upload
  44380. */
  44381. export interface EnvironmentTextureInfo {
  44382. /**
  44383. * Version of the environment map
  44384. */
  44385. version: number;
  44386. /**
  44387. * Width of image
  44388. */
  44389. width: number;
  44390. /**
  44391. * Irradiance information stored in the file.
  44392. */
  44393. irradiance: any;
  44394. /**
  44395. * Specular information stored in the file.
  44396. */
  44397. specular: any;
  44398. }
  44399. /**
  44400. * Defines One Image in the file. It requires only the position in the file
  44401. * as well as the length.
  44402. */
  44403. interface BufferImageData {
  44404. /**
  44405. * Length of the image data.
  44406. */
  44407. length: number;
  44408. /**
  44409. * Position of the data from the null terminator delimiting the end of the JSON.
  44410. */
  44411. position: number;
  44412. }
  44413. /**
  44414. * Defines the specular data enclosed in the file.
  44415. * This corresponds to the version 1 of the data.
  44416. */
  44417. export interface EnvironmentTextureSpecularInfoV1 {
  44418. /**
  44419. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  44420. */
  44421. specularDataPosition?: number;
  44422. /**
  44423. * This contains all the images data needed to reconstruct the cubemap.
  44424. */
  44425. mipmaps: Array<BufferImageData>;
  44426. /**
  44427. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  44428. */
  44429. lodGenerationScale: number;
  44430. }
  44431. /**
  44432. * Sets of helpers addressing the serialization and deserialization of environment texture
  44433. * stored in a BabylonJS env file.
  44434. * Those files are usually stored as .env files.
  44435. */
  44436. export class EnvironmentTextureTools {
  44437. /**
  44438. * Magic number identifying the env file.
  44439. */
  44440. private static _MagicBytes;
  44441. /**
  44442. * Gets the environment info from an env file.
  44443. * @param data The array buffer containing the .env bytes.
  44444. * @returns the environment file info (the json header) if successfully parsed.
  44445. */
  44446. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44447. /**
  44448. * Creates an environment texture from a loaded cube texture.
  44449. * @param texture defines the cube texture to convert in env file
  44450. * @return a promise containing the environment data if succesfull.
  44451. */
  44452. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44453. /**
  44454. * Creates a JSON representation of the spherical data.
  44455. * @param texture defines the texture containing the polynomials
  44456. * @return the JSON representation of the spherical info
  44457. */
  44458. private static _CreateEnvTextureIrradiance;
  44459. /**
  44460. * Creates the ArrayBufferViews used for initializing environment texture image data.
  44461. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  44462. * @param info parameters that determine what views will be created for accessing the underlying buffer
  44463. * @return the views described by info providing access to the underlying buffer
  44464. */
  44465. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  44466. /**
  44467. * Uploads the texture info contained in the env file to the GPU.
  44468. * @param texture defines the internal texture to upload to
  44469. * @param arrayBuffer defines the buffer cotaining the data to load
  44470. * @param info defines the texture info retrieved through the GetEnvInfo method
  44471. * @returns a promise
  44472. */
  44473. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44474. /**
  44475. * Uploads the levels of image data to the GPU.
  44476. * @param texture defines the internal texture to upload to
  44477. * @param imageData defines the array buffer views of image data [mipmap][face]
  44478. * @returns a promise
  44479. */
  44480. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44481. /**
  44482. * Uploads spherical polynomials information to the texture.
  44483. * @param texture defines the texture we are trying to upload the information to
  44484. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  44485. */
  44486. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  44487. /** @hidden */
  44488. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44489. }
  44490. }
  44491. declare module BABYLON {
  44492. /**
  44493. * Contains position and normal vectors for a vertex
  44494. */
  44495. export class PositionNormalVertex {
  44496. /** the position of the vertex (defaut: 0,0,0) */
  44497. position: Vector3;
  44498. /** the normal of the vertex (defaut: 0,1,0) */
  44499. normal: Vector3;
  44500. /**
  44501. * Creates a PositionNormalVertex
  44502. * @param position the position of the vertex (defaut: 0,0,0)
  44503. * @param normal the normal of the vertex (defaut: 0,1,0)
  44504. */
  44505. constructor(
  44506. /** the position of the vertex (defaut: 0,0,0) */
  44507. position?: Vector3,
  44508. /** the normal of the vertex (defaut: 0,1,0) */
  44509. normal?: Vector3);
  44510. /**
  44511. * Clones the PositionNormalVertex
  44512. * @returns the cloned PositionNormalVertex
  44513. */
  44514. clone(): PositionNormalVertex;
  44515. }
  44516. /**
  44517. * Contains position, normal and uv vectors for a vertex
  44518. */
  44519. export class PositionNormalTextureVertex {
  44520. /** the position of the vertex (defaut: 0,0,0) */
  44521. position: Vector3;
  44522. /** the normal of the vertex (defaut: 0,1,0) */
  44523. normal: Vector3;
  44524. /** the uv of the vertex (default: 0,0) */
  44525. uv: Vector2;
  44526. /**
  44527. * Creates a PositionNormalTextureVertex
  44528. * @param position the position of the vertex (defaut: 0,0,0)
  44529. * @param normal the normal of the vertex (defaut: 0,1,0)
  44530. * @param uv the uv of the vertex (default: 0,0)
  44531. */
  44532. constructor(
  44533. /** the position of the vertex (defaut: 0,0,0) */
  44534. position?: Vector3,
  44535. /** the normal of the vertex (defaut: 0,1,0) */
  44536. normal?: Vector3,
  44537. /** the uv of the vertex (default: 0,0) */
  44538. uv?: Vector2);
  44539. /**
  44540. * Clones the PositionNormalTextureVertex
  44541. * @returns the cloned PositionNormalTextureVertex
  44542. */
  44543. clone(): PositionNormalTextureVertex;
  44544. }
  44545. }
  44546. declare module BABYLON {
  44547. /** @hidden */
  44548. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44549. private _genericAttributeLocation;
  44550. private _varyingLocationCount;
  44551. private _varyingLocationMap;
  44552. private _replacements;
  44553. private _textureCount;
  44554. private _uniforms;
  44555. lineProcessor(line: string): string;
  44556. attributeProcessor(attribute: string): string;
  44557. varyingProcessor(varying: string, isFragment: boolean): string;
  44558. uniformProcessor(uniform: string): string;
  44559. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44560. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44561. }
  44562. }
  44563. declare module BABYLON {
  44564. /**
  44565. * Container for accessors for natively-stored mesh data buffers.
  44566. */
  44567. class NativeDataBuffer extends DataBuffer {
  44568. /**
  44569. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44570. */
  44571. nativeIndexBuffer?: any;
  44572. /**
  44573. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44574. */
  44575. nativeVertexBuffer?: any;
  44576. }
  44577. /** @hidden */
  44578. export class NativeEngine extends Engine {
  44579. private readonly _native;
  44580. getHardwareScalingLevel(): number;
  44581. constructor();
  44582. /**
  44583. * Can be used to override the current requestAnimationFrame requester.
  44584. * @hidden
  44585. */
  44586. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44587. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44588. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44589. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44590. recordVertexArrayObject(vertexBuffers: {
  44591. [key: string]: VertexBuffer;
  44592. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44593. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44594. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44595. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44596. /**
  44597. * Draw a list of indexed primitives
  44598. * @param fillMode defines the primitive to use
  44599. * @param indexStart defines the starting index
  44600. * @param indexCount defines the number of index to draw
  44601. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44602. */
  44603. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44604. /**
  44605. * Draw a list of unindexed primitives
  44606. * @param fillMode defines the primitive to use
  44607. * @param verticesStart defines the index of first vertex to draw
  44608. * @param verticesCount defines the count of vertices to draw
  44609. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44610. */
  44611. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44612. createPipelineContext(): IPipelineContext;
  44613. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44614. /** @hidden */
  44615. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44616. /** @hidden */
  44617. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44618. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44619. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44620. protected _setProgram(program: WebGLProgram): void;
  44621. _releaseEffect(effect: Effect): void;
  44622. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44623. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44624. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44625. bindSamplers(effect: Effect): void;
  44626. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44627. getRenderWidth(useScreen?: boolean): number;
  44628. getRenderHeight(useScreen?: boolean): number;
  44629. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44630. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44631. /**
  44632. * Set the z offset to apply to current rendering
  44633. * @param value defines the offset to apply
  44634. */
  44635. setZOffset(value: number): void;
  44636. /**
  44637. * Gets the current value of the zOffset
  44638. * @returns the current zOffset state
  44639. */
  44640. getZOffset(): number;
  44641. /**
  44642. * Enable or disable depth buffering
  44643. * @param enable defines the state to set
  44644. */
  44645. setDepthBuffer(enable: boolean): void;
  44646. /**
  44647. * Gets a boolean indicating if depth writing is enabled
  44648. * @returns the current depth writing state
  44649. */
  44650. getDepthWrite(): boolean;
  44651. /**
  44652. * Enable or disable depth writing
  44653. * @param enable defines the state to set
  44654. */
  44655. setDepthWrite(enable: boolean): void;
  44656. /**
  44657. * Enable or disable color writing
  44658. * @param enable defines the state to set
  44659. */
  44660. setColorWrite(enable: boolean): void;
  44661. /**
  44662. * Gets a boolean indicating if color writing is enabled
  44663. * @returns the current color writing state
  44664. */
  44665. getColorWrite(): boolean;
  44666. /**
  44667. * Sets alpha constants used by some alpha blending modes
  44668. * @param r defines the red component
  44669. * @param g defines the green component
  44670. * @param b defines the blue component
  44671. * @param a defines the alpha component
  44672. */
  44673. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44674. /**
  44675. * Sets the current alpha mode
  44676. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  44677. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44678. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44679. */
  44680. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44681. /**
  44682. * Gets the current alpha mode
  44683. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44684. * @returns the current alpha mode
  44685. */
  44686. getAlphaMode(): number;
  44687. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44688. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44689. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44690. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44691. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44692. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44693. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44694. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44695. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44696. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44697. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44698. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44699. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44700. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44701. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44702. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44703. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44704. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44705. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44706. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44707. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44708. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44709. wipeCaches(bruteForce?: boolean): void;
  44710. _createTexture(): WebGLTexture;
  44711. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44712. /**
  44713. * Usually called from BABYLON.Texture.ts.
  44714. * Passed information to create a WebGLTexture
  44715. * @param urlArg defines a value which contains one of the following:
  44716. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44717. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44718. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44719. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44720. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44721. * @param scene needed for loading to the correct scene
  44722. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44723. * @param onLoad optional callback to be called upon successful completion
  44724. * @param onError optional callback to be called upon failure
  44725. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44726. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44727. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44728. * @param forcedExtension defines the extension to use to pick the right loader
  44729. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44730. */
  44731. 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 | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  44732. /**
  44733. * Creates a cube texture
  44734. * @param rootUrl defines the url where the files to load is located
  44735. * @param scene defines the current scene
  44736. * @param files defines the list of files to load (1 per face)
  44737. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44738. * @param onLoad defines an optional callback raised when the texture is loaded
  44739. * @param onError defines an optional callback raised if there is an issue to load the texture
  44740. * @param format defines the format of the data
  44741. * @param forcedExtension defines the extension to use to pick the right loader
  44742. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44743. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44744. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44745. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44746. * @returns the cube texture as an InternalTexture
  44747. */
  44748. 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, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  44749. private _getSamplingFilter;
  44750. private static _GetNativeTextureFormat;
  44751. createRenderTargetTexture(size: number | {
  44752. width: number;
  44753. height: number;
  44754. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44755. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44756. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44757. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44758. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44759. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44760. /**
  44761. * Updates a dynamic vertex buffer.
  44762. * @param vertexBuffer the vertex buffer to update
  44763. * @param data the data used to update the vertex buffer
  44764. * @param byteOffset the byte offset of the data (optional)
  44765. * @param byteLength the byte length of the data (optional)
  44766. */
  44767. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44768. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44769. private _updateAnisotropicLevel;
  44770. private _getAddressMode;
  44771. /** @hidden */
  44772. _bindTexture(channel: number, texture: InternalTexture): void;
  44773. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44774. releaseEffects(): void;
  44775. /** @hidden */
  44776. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44777. /** @hidden */
  44778. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44779. /** @hidden */
  44780. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44781. /** @hidden */
  44782. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44783. }
  44784. }
  44785. declare module BABYLON {
  44786. /**
  44787. * Gather the list of clipboard event types as constants.
  44788. */
  44789. export class ClipboardEventTypes {
  44790. /**
  44791. * The clipboard event is fired when a copy command is active (pressed).
  44792. */
  44793. static readonly COPY: number;
  44794. /**
  44795. * The clipboard event is fired when a cut command is active (pressed).
  44796. */
  44797. static readonly CUT: number;
  44798. /**
  44799. * The clipboard event is fired when a paste command is active (pressed).
  44800. */
  44801. static readonly PASTE: number;
  44802. }
  44803. /**
  44804. * This class is used to store clipboard related info for the onClipboardObservable event.
  44805. */
  44806. export class ClipboardInfo {
  44807. /**
  44808. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44809. */
  44810. type: number;
  44811. /**
  44812. * Defines the related dom event
  44813. */
  44814. event: ClipboardEvent;
  44815. /**
  44816. *Creates an instance of ClipboardInfo.
  44817. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44818. * @param event Defines the related dom event
  44819. */
  44820. constructor(
  44821. /**
  44822. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44823. */
  44824. type: number,
  44825. /**
  44826. * Defines the related dom event
  44827. */
  44828. event: ClipboardEvent);
  44829. /**
  44830. * Get the clipboard event's type from the keycode.
  44831. * @param keyCode Defines the keyCode for the current keyboard event.
  44832. * @return {number}
  44833. */
  44834. static GetTypeFromCharacter(keyCode: number): number;
  44835. }
  44836. }
  44837. declare module BABYLON {
  44838. /**
  44839. * Google Daydream controller
  44840. */
  44841. export class DaydreamController extends WebVRController {
  44842. /**
  44843. * Base Url for the controller model.
  44844. */
  44845. static MODEL_BASE_URL: string;
  44846. /**
  44847. * File name for the controller model.
  44848. */
  44849. static MODEL_FILENAME: string;
  44850. /**
  44851. * Gamepad Id prefix used to identify Daydream Controller.
  44852. */
  44853. static readonly GAMEPAD_ID_PREFIX: string;
  44854. /**
  44855. * Creates a new DaydreamController from a gamepad
  44856. * @param vrGamepad the gamepad that the controller should be created from
  44857. */
  44858. constructor(vrGamepad: any);
  44859. /**
  44860. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44861. * @param scene scene in which to add meshes
  44862. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44863. */
  44864. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44865. /**
  44866. * Called once for each button that changed state since the last frame
  44867. * @param buttonIdx Which button index changed
  44868. * @param state New state of the button
  44869. * @param changes Which properties on the state changed since last frame
  44870. */
  44871. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44872. }
  44873. }
  44874. declare module BABYLON {
  44875. /**
  44876. * Gear VR Controller
  44877. */
  44878. export class GearVRController extends WebVRController {
  44879. /**
  44880. * Base Url for the controller model.
  44881. */
  44882. static MODEL_BASE_URL: string;
  44883. /**
  44884. * File name for the controller model.
  44885. */
  44886. static MODEL_FILENAME: string;
  44887. /**
  44888. * Gamepad Id prefix used to identify this controller.
  44889. */
  44890. static readonly GAMEPAD_ID_PREFIX: string;
  44891. private readonly _buttonIndexToObservableNameMap;
  44892. /**
  44893. * Creates a new GearVRController from a gamepad
  44894. * @param vrGamepad the gamepad that the controller should be created from
  44895. */
  44896. constructor(vrGamepad: any);
  44897. /**
  44898. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44899. * @param scene scene in which to add meshes
  44900. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44901. */
  44902. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44903. /**
  44904. * Called once for each button that changed state since the last frame
  44905. * @param buttonIdx Which button index changed
  44906. * @param state New state of the button
  44907. * @param changes Which properties on the state changed since last frame
  44908. */
  44909. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44910. }
  44911. }
  44912. declare module BABYLON {
  44913. /**
  44914. * Class containing static functions to help procedurally build meshes
  44915. */
  44916. export class PolyhedronBuilder {
  44917. /**
  44918. * Creates a polyhedron mesh
  44919. * * 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
  44920. * * The parameter `size` (positive float, default 1) sets the polygon size
  44921. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44922. * * 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`
  44923. * * 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
  44924. * * 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)`)
  44925. * * 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
  44926. * * 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
  44927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44928. * * 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
  44929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44930. * @param name defines the name of the mesh
  44931. * @param options defines the options used to create the mesh
  44932. * @param scene defines the hosting scene
  44933. * @returns the polyhedron mesh
  44934. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44935. */
  44936. static CreatePolyhedron(name: string, options: {
  44937. type?: number;
  44938. size?: number;
  44939. sizeX?: number;
  44940. sizeY?: number;
  44941. sizeZ?: number;
  44942. custom?: any;
  44943. faceUV?: Vector4[];
  44944. faceColors?: Color4[];
  44945. flat?: boolean;
  44946. updatable?: boolean;
  44947. sideOrientation?: number;
  44948. frontUVs?: Vector4;
  44949. backUVs?: Vector4;
  44950. }, scene?: Nullable<Scene>): Mesh;
  44951. }
  44952. }
  44953. declare module BABYLON {
  44954. /**
  44955. * Gizmo that enables scaling a mesh along 3 axis
  44956. */
  44957. export class ScaleGizmo extends Gizmo {
  44958. /**
  44959. * Internal gizmo used for interactions on the x axis
  44960. */
  44961. xGizmo: AxisScaleGizmo;
  44962. /**
  44963. * Internal gizmo used for interactions on the y axis
  44964. */
  44965. yGizmo: AxisScaleGizmo;
  44966. /**
  44967. * Internal gizmo used for interactions on the z axis
  44968. */
  44969. zGizmo: AxisScaleGizmo;
  44970. /**
  44971. * Internal gizmo used to scale all axis equally
  44972. */
  44973. uniformScaleGizmo: AxisScaleGizmo;
  44974. private _meshAttached;
  44975. private _updateGizmoRotationToMatchAttachedMesh;
  44976. private _snapDistance;
  44977. private _scaleRatio;
  44978. private _uniformScalingMesh;
  44979. private _octahedron;
  44980. /** Fires an event when any of it's sub gizmos are dragged */
  44981. onDragStartObservable: Observable<unknown>;
  44982. /** Fires an event when any of it's sub gizmos are released from dragging */
  44983. onDragEndObservable: Observable<unknown>;
  44984. attachedMesh: Nullable<AbstractMesh>;
  44985. /**
  44986. * Creates a ScaleGizmo
  44987. * @param gizmoLayer The utility layer the gizmo will be added to
  44988. */
  44989. constructor(gizmoLayer?: UtilityLayerRenderer);
  44990. updateGizmoRotationToMatchAttachedMesh: boolean;
  44991. /**
  44992. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44993. */
  44994. snapDistance: number;
  44995. /**
  44996. * Ratio for the scale of the gizmo (Default: 1)
  44997. */
  44998. scaleRatio: number;
  44999. /**
  45000. * Disposes of the gizmo
  45001. */
  45002. dispose(): void;
  45003. }
  45004. }
  45005. declare module BABYLON {
  45006. /**
  45007. * Single axis scale gizmo
  45008. */
  45009. export class AxisScaleGizmo extends Gizmo {
  45010. /**
  45011. * Drag behavior responsible for the gizmos dragging interactions
  45012. */
  45013. dragBehavior: PointerDragBehavior;
  45014. private _pointerObserver;
  45015. /**
  45016. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45017. */
  45018. snapDistance: number;
  45019. /**
  45020. * Event that fires each time the gizmo snaps to a new location.
  45021. * * snapDistance is the the change in distance
  45022. */
  45023. onSnapObservable: Observable<{
  45024. snapDistance: number;
  45025. }>;
  45026. /**
  45027. * If the scaling operation should be done on all axis (default: false)
  45028. */
  45029. uniformScaling: boolean;
  45030. private _isEnabled;
  45031. private _parent;
  45032. private _arrow;
  45033. private _coloredMaterial;
  45034. private _hoverMaterial;
  45035. /**
  45036. * Creates an AxisScaleGizmo
  45037. * @param gizmoLayer The utility layer the gizmo will be added to
  45038. * @param dragAxis The axis which the gizmo will be able to scale on
  45039. * @param color The color of the gizmo
  45040. */
  45041. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45042. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45043. /**
  45044. * If the gizmo is enabled
  45045. */
  45046. isEnabled: boolean;
  45047. /**
  45048. * Disposes of the gizmo
  45049. */
  45050. dispose(): void;
  45051. /**
  45052. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45053. * @param mesh The mesh to replace the default mesh of the gizmo
  45054. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45055. */
  45056. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45057. }
  45058. }
  45059. declare module BABYLON {
  45060. /**
  45061. * Bounding box gizmo
  45062. */
  45063. export class BoundingBoxGizmo extends Gizmo {
  45064. private _lineBoundingBox;
  45065. private _rotateSpheresParent;
  45066. private _scaleBoxesParent;
  45067. private _boundingDimensions;
  45068. private _renderObserver;
  45069. private _pointerObserver;
  45070. private _scaleDragSpeed;
  45071. private _tmpQuaternion;
  45072. private _tmpVector;
  45073. private _tmpRotationMatrix;
  45074. /**
  45075. * 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)
  45076. */
  45077. ignoreChildren: boolean;
  45078. /**
  45079. * 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)
  45080. */
  45081. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45082. /**
  45083. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45084. */
  45085. rotationSphereSize: number;
  45086. /**
  45087. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45088. */
  45089. scaleBoxSize: number;
  45090. /**
  45091. * 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)
  45092. */
  45093. fixedDragMeshScreenSize: boolean;
  45094. /**
  45095. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45096. */
  45097. fixedDragMeshScreenSizeDistanceFactor: number;
  45098. /**
  45099. * Fired when a rotation sphere or scale box is dragged
  45100. */
  45101. onDragStartObservable: Observable<{}>;
  45102. /**
  45103. * Fired when a scale box is dragged
  45104. */
  45105. onScaleBoxDragObservable: Observable<{}>;
  45106. /**
  45107. * Fired when a scale box drag is ended
  45108. */
  45109. onScaleBoxDragEndObservable: Observable<{}>;
  45110. /**
  45111. * Fired when a rotation sphere is dragged
  45112. */
  45113. onRotationSphereDragObservable: Observable<{}>;
  45114. /**
  45115. * Fired when a rotation sphere drag is ended
  45116. */
  45117. onRotationSphereDragEndObservable: Observable<{}>;
  45118. /**
  45119. * 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)
  45120. */
  45121. scalePivot: Nullable<Vector3>;
  45122. /**
  45123. * Mesh used as a pivot to rotate the attached mesh
  45124. */
  45125. private _anchorMesh;
  45126. private _existingMeshScale;
  45127. private _dragMesh;
  45128. private pointerDragBehavior;
  45129. private coloredMaterial;
  45130. private hoverColoredMaterial;
  45131. /**
  45132. * Sets the color of the bounding box gizmo
  45133. * @param color the color to set
  45134. */
  45135. setColor(color: Color3): void;
  45136. /**
  45137. * Creates an BoundingBoxGizmo
  45138. * @param gizmoLayer The utility layer the gizmo will be added to
  45139. * @param color The color of the gizmo
  45140. */
  45141. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45142. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45143. private _selectNode;
  45144. /**
  45145. * Updates the bounding box information for the Gizmo
  45146. */
  45147. updateBoundingBox(): void;
  45148. private _updateRotationSpheres;
  45149. private _updateScaleBoxes;
  45150. /**
  45151. * Enables rotation on the specified axis and disables rotation on the others
  45152. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45153. */
  45154. setEnabledRotationAxis(axis: string): void;
  45155. /**
  45156. * Enables/disables scaling
  45157. * @param enable if scaling should be enabled
  45158. */
  45159. setEnabledScaling(enable: boolean): void;
  45160. private _updateDummy;
  45161. /**
  45162. * Enables a pointer drag behavior on the bounding box of the gizmo
  45163. */
  45164. enableDragBehavior(): void;
  45165. /**
  45166. * Disposes of the gizmo
  45167. */
  45168. dispose(): void;
  45169. /**
  45170. * 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)
  45171. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45172. * @returns the bounding box mesh with the passed in mesh as a child
  45173. */
  45174. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45175. /**
  45176. * CustomMeshes are not supported by this gizmo
  45177. * @param mesh The mesh to replace the default mesh of the gizmo
  45178. */
  45179. setCustomMesh(mesh: Mesh): void;
  45180. }
  45181. }
  45182. declare module BABYLON {
  45183. /**
  45184. * Single plane rotation gizmo
  45185. */
  45186. export class PlaneRotationGizmo extends Gizmo {
  45187. /**
  45188. * Drag behavior responsible for the gizmos dragging interactions
  45189. */
  45190. dragBehavior: PointerDragBehavior;
  45191. private _pointerObserver;
  45192. /**
  45193. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45194. */
  45195. snapDistance: number;
  45196. /**
  45197. * Event that fires each time the gizmo snaps to a new location.
  45198. * * snapDistance is the the change in distance
  45199. */
  45200. onSnapObservable: Observable<{
  45201. snapDistance: number;
  45202. }>;
  45203. private _isEnabled;
  45204. private _parent;
  45205. /**
  45206. * Creates a PlaneRotationGizmo
  45207. * @param gizmoLayer The utility layer the gizmo will be added to
  45208. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45209. * @param color The color of the gizmo
  45210. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45211. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45212. */
  45213. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45214. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45215. /**
  45216. * If the gizmo is enabled
  45217. */
  45218. isEnabled: boolean;
  45219. /**
  45220. * Disposes of the gizmo
  45221. */
  45222. dispose(): void;
  45223. }
  45224. }
  45225. declare module BABYLON {
  45226. /**
  45227. * Gizmo that enables rotating a mesh along 3 axis
  45228. */
  45229. export class RotationGizmo extends Gizmo {
  45230. /**
  45231. * Internal gizmo used for interactions on the x axis
  45232. */
  45233. xGizmo: PlaneRotationGizmo;
  45234. /**
  45235. * Internal gizmo used for interactions on the y axis
  45236. */
  45237. yGizmo: PlaneRotationGizmo;
  45238. /**
  45239. * Internal gizmo used for interactions on the z axis
  45240. */
  45241. zGizmo: PlaneRotationGizmo;
  45242. /** Fires an event when any of it's sub gizmos are dragged */
  45243. onDragStartObservable: Observable<unknown>;
  45244. /** Fires an event when any of it's sub gizmos are released from dragging */
  45245. onDragEndObservable: Observable<unknown>;
  45246. private _meshAttached;
  45247. attachedMesh: Nullable<AbstractMesh>;
  45248. /**
  45249. * Creates a RotationGizmo
  45250. * @param gizmoLayer The utility layer the gizmo will be added to
  45251. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45252. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45253. */
  45254. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45255. updateGizmoRotationToMatchAttachedMesh: boolean;
  45256. /**
  45257. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45258. */
  45259. snapDistance: number;
  45260. /**
  45261. * Ratio for the scale of the gizmo (Default: 1)
  45262. */
  45263. scaleRatio: number;
  45264. /**
  45265. * Disposes of the gizmo
  45266. */
  45267. dispose(): void;
  45268. /**
  45269. * CustomMeshes are not supported by this gizmo
  45270. * @param mesh The mesh to replace the default mesh of the gizmo
  45271. */
  45272. setCustomMesh(mesh: Mesh): void;
  45273. }
  45274. }
  45275. declare module BABYLON {
  45276. /**
  45277. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45278. */
  45279. export class GizmoManager implements IDisposable {
  45280. private scene;
  45281. /**
  45282. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45283. */
  45284. gizmos: {
  45285. positionGizmo: Nullable<PositionGizmo>;
  45286. rotationGizmo: Nullable<RotationGizmo>;
  45287. scaleGizmo: Nullable<ScaleGizmo>;
  45288. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45289. };
  45290. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45291. clearGizmoOnEmptyPointerEvent: boolean;
  45292. /** Fires an event when the manager is attached to a mesh */
  45293. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45294. private _gizmosEnabled;
  45295. private _pointerObserver;
  45296. private _attachedMesh;
  45297. private _boundingBoxColor;
  45298. private _defaultUtilityLayer;
  45299. private _defaultKeepDepthUtilityLayer;
  45300. /**
  45301. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45302. */
  45303. boundingBoxDragBehavior: SixDofDragBehavior;
  45304. /**
  45305. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45306. */
  45307. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45308. /**
  45309. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45310. */
  45311. usePointerToAttachGizmos: boolean;
  45312. /**
  45313. * Utility layer that the bounding box gizmo belongs to
  45314. */
  45315. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45316. /**
  45317. * Utility layer that all gizmos besides bounding box belong to
  45318. */
  45319. readonly utilityLayer: UtilityLayerRenderer;
  45320. /**
  45321. * Instatiates a gizmo manager
  45322. * @param scene the scene to overlay the gizmos on top of
  45323. */
  45324. constructor(scene: Scene);
  45325. /**
  45326. * Attaches a set of gizmos to the specified mesh
  45327. * @param mesh The mesh the gizmo's should be attached to
  45328. */
  45329. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45330. /**
  45331. * If the position gizmo is enabled
  45332. */
  45333. positionGizmoEnabled: boolean;
  45334. /**
  45335. * If the rotation gizmo is enabled
  45336. */
  45337. rotationGizmoEnabled: boolean;
  45338. /**
  45339. * If the scale gizmo is enabled
  45340. */
  45341. scaleGizmoEnabled: boolean;
  45342. /**
  45343. * If the boundingBox gizmo is enabled
  45344. */
  45345. boundingBoxGizmoEnabled: boolean;
  45346. /**
  45347. * Disposes of the gizmo manager
  45348. */
  45349. dispose(): void;
  45350. }
  45351. }
  45352. declare module BABYLON {
  45353. /**
  45354. * A directional light is defined by a direction (what a surprise!).
  45355. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45356. * 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.
  45357. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45358. */
  45359. export class DirectionalLight extends ShadowLight {
  45360. private _shadowFrustumSize;
  45361. /**
  45362. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45363. */
  45364. /**
  45365. * Specifies a fix frustum size for the shadow generation.
  45366. */
  45367. shadowFrustumSize: number;
  45368. private _shadowOrthoScale;
  45369. /**
  45370. * Gets the shadow projection scale against the optimal computed one.
  45371. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45372. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45373. */
  45374. /**
  45375. * Sets the shadow projection scale against the optimal computed one.
  45376. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45377. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45378. */
  45379. shadowOrthoScale: number;
  45380. /**
  45381. * Automatically compute the projection matrix to best fit (including all the casters)
  45382. * on each frame.
  45383. */
  45384. autoUpdateExtends: boolean;
  45385. private _orthoLeft;
  45386. private _orthoRight;
  45387. private _orthoTop;
  45388. private _orthoBottom;
  45389. /**
  45390. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45391. * The directional light is emitted from everywhere in the given direction.
  45392. * It can cast shadows.
  45393. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45394. * @param name The friendly name of the light
  45395. * @param direction The direction of the light
  45396. * @param scene The scene the light belongs to
  45397. */
  45398. constructor(name: string, direction: Vector3, scene: Scene);
  45399. /**
  45400. * Returns the string "DirectionalLight".
  45401. * @return The class name
  45402. */
  45403. getClassName(): string;
  45404. /**
  45405. * Returns the integer 1.
  45406. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45407. */
  45408. getTypeID(): number;
  45409. /**
  45410. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45411. * Returns the DirectionalLight Shadow projection matrix.
  45412. */
  45413. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45414. /**
  45415. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45416. * Returns the DirectionalLight Shadow projection matrix.
  45417. */
  45418. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45419. /**
  45420. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45421. * Returns the DirectionalLight Shadow projection matrix.
  45422. */
  45423. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45424. protected _buildUniformLayout(): void;
  45425. /**
  45426. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45427. * @param effect The effect to update
  45428. * @param lightIndex The index of the light in the effect to update
  45429. * @returns The directional light
  45430. */
  45431. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45432. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  45433. /**
  45434. * Gets the minZ used for shadow according to both the scene and the light.
  45435. *
  45436. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45437. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45438. * @param activeCamera The camera we are returning the min for
  45439. * @returns the depth min z
  45440. */
  45441. getDepthMinZ(activeCamera: Camera): number;
  45442. /**
  45443. * Gets the maxZ used for shadow according to both the scene and the light.
  45444. *
  45445. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45446. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45447. * @param activeCamera The camera we are returning the max for
  45448. * @returns the depth max z
  45449. */
  45450. getDepthMaxZ(activeCamera: Camera): number;
  45451. /**
  45452. * Prepares the list of defines specific to the light type.
  45453. * @param defines the list of defines
  45454. * @param lightIndex defines the index of the light for the effect
  45455. */
  45456. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45457. }
  45458. }
  45459. declare module BABYLON {
  45460. /**
  45461. * Class containing static functions to help procedurally build meshes
  45462. */
  45463. export class HemisphereBuilder {
  45464. /**
  45465. * Creates a hemisphere mesh
  45466. * @param name defines the name of the mesh
  45467. * @param options defines the options used to create the mesh
  45468. * @param scene defines the hosting scene
  45469. * @returns the hemisphere mesh
  45470. */
  45471. static CreateHemisphere(name: string, options: {
  45472. segments?: number;
  45473. diameter?: number;
  45474. sideOrientation?: number;
  45475. }, scene: any): Mesh;
  45476. }
  45477. }
  45478. declare module BABYLON {
  45479. /**
  45480. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45481. * These values define a cone of light starting from the position, emitting toward the direction.
  45482. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45483. * and the exponent defines the speed of the decay of the light with distance (reach).
  45484. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45485. */
  45486. export class SpotLight extends ShadowLight {
  45487. private _angle;
  45488. private _innerAngle;
  45489. private _cosHalfAngle;
  45490. private _lightAngleScale;
  45491. private _lightAngleOffset;
  45492. /**
  45493. * Gets the cone angle of the spot light in Radians.
  45494. */
  45495. /**
  45496. * Sets the cone angle of the spot light in Radians.
  45497. */
  45498. angle: number;
  45499. /**
  45500. * Only used in gltf falloff mode, this defines the angle where
  45501. * the directional falloff will start before cutting at angle which could be seen
  45502. * as outer angle.
  45503. */
  45504. /**
  45505. * Only used in gltf falloff mode, this defines the angle where
  45506. * the directional falloff will start before cutting at angle which could be seen
  45507. * as outer angle.
  45508. */
  45509. innerAngle: number;
  45510. private _shadowAngleScale;
  45511. /**
  45512. * Allows scaling the angle of the light for shadow generation only.
  45513. */
  45514. /**
  45515. * Allows scaling the angle of the light for shadow generation only.
  45516. */
  45517. shadowAngleScale: number;
  45518. /**
  45519. * The light decay speed with the distance from the emission spot.
  45520. */
  45521. exponent: number;
  45522. private _projectionTextureMatrix;
  45523. /**
  45524. * Allows reading the projecton texture
  45525. */
  45526. readonly projectionTextureMatrix: Matrix;
  45527. protected _projectionTextureLightNear: number;
  45528. /**
  45529. * Gets the near clip of the Spotlight for texture projection.
  45530. */
  45531. /**
  45532. * Sets the near clip of the Spotlight for texture projection.
  45533. */
  45534. projectionTextureLightNear: number;
  45535. protected _projectionTextureLightFar: number;
  45536. /**
  45537. * Gets the far clip of the Spotlight for texture projection.
  45538. */
  45539. /**
  45540. * Sets the far clip of the Spotlight for texture projection.
  45541. */
  45542. projectionTextureLightFar: number;
  45543. protected _projectionTextureUpDirection: Vector3;
  45544. /**
  45545. * Gets the Up vector of the Spotlight for texture projection.
  45546. */
  45547. /**
  45548. * Sets the Up vector of the Spotlight for texture projection.
  45549. */
  45550. projectionTextureUpDirection: Vector3;
  45551. private _projectionTexture;
  45552. /**
  45553. * Gets the projection texture of the light.
  45554. */
  45555. /**
  45556. * Sets the projection texture of the light.
  45557. */
  45558. projectionTexture: Nullable<BaseTexture>;
  45559. private _projectionTextureViewLightDirty;
  45560. private _projectionTextureProjectionLightDirty;
  45561. private _projectionTextureDirty;
  45562. private _projectionTextureViewTargetVector;
  45563. private _projectionTextureViewLightMatrix;
  45564. private _projectionTextureProjectionLightMatrix;
  45565. private _projectionTextureScalingMatrix;
  45566. /**
  45567. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45568. * It can cast shadows.
  45569. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45570. * @param name The light friendly name
  45571. * @param position The position of the spot light in the scene
  45572. * @param direction The direction of the light in the scene
  45573. * @param angle The cone angle of the light in Radians
  45574. * @param exponent The light decay speed with the distance from the emission spot
  45575. * @param scene The scene the lights belongs to
  45576. */
  45577. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45578. /**
  45579. * Returns the string "SpotLight".
  45580. * @returns the class name
  45581. */
  45582. getClassName(): string;
  45583. /**
  45584. * Returns the integer 2.
  45585. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45586. */
  45587. getTypeID(): number;
  45588. /**
  45589. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45590. */
  45591. protected _setDirection(value: Vector3): void;
  45592. /**
  45593. * Overrides the position setter to recompute the projection texture view light Matrix.
  45594. */
  45595. protected _setPosition(value: Vector3): void;
  45596. /**
  45597. * 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.
  45598. * Returns the SpotLight.
  45599. */
  45600. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45601. protected _computeProjectionTextureViewLightMatrix(): void;
  45602. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45603. /**
  45604. * Main function for light texture projection matrix computing.
  45605. */
  45606. protected _computeProjectionTextureMatrix(): void;
  45607. protected _buildUniformLayout(): void;
  45608. private _computeAngleValues;
  45609. /**
  45610. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45611. * @param effect The effect to update
  45612. * @param lightIndex The index of the light in the effect to update
  45613. * @returns The spot light
  45614. */
  45615. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45616. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45617. /**
  45618. * Disposes the light and the associated resources.
  45619. */
  45620. dispose(): void;
  45621. /**
  45622. * Prepares the list of defines specific to the light type.
  45623. * @param defines the list of defines
  45624. * @param lightIndex defines the index of the light for the effect
  45625. */
  45626. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45627. }
  45628. }
  45629. declare module BABYLON {
  45630. /**
  45631. * Gizmo that enables viewing a light
  45632. */
  45633. export class LightGizmo extends Gizmo {
  45634. private _lightMesh;
  45635. private _material;
  45636. private cachedPosition;
  45637. private cachedForward;
  45638. /**
  45639. * Creates a LightGizmo
  45640. * @param gizmoLayer The utility layer the gizmo will be added to
  45641. */
  45642. constructor(gizmoLayer?: UtilityLayerRenderer);
  45643. private _light;
  45644. /**
  45645. * The light that the gizmo is attached to
  45646. */
  45647. light: Nullable<Light>;
  45648. /**
  45649. * Gets the material used to render the light gizmo
  45650. */
  45651. readonly material: StandardMaterial;
  45652. /**
  45653. * @hidden
  45654. * Updates the gizmo to match the attached mesh's position/rotation
  45655. */
  45656. protected _update(): void;
  45657. private static _Scale;
  45658. /**
  45659. * Creates the lines for a light mesh
  45660. */
  45661. private static _createLightLines;
  45662. /**
  45663. * Disposes of the light gizmo
  45664. */
  45665. dispose(): void;
  45666. private static _CreateHemisphericLightMesh;
  45667. private static _CreatePointLightMesh;
  45668. private static _CreateSpotLightMesh;
  45669. private static _CreateDirectionalLightMesh;
  45670. }
  45671. }
  45672. declare module BABYLON {
  45673. /** @hidden */
  45674. export var backgroundFragmentDeclaration: {
  45675. name: string;
  45676. shader: string;
  45677. };
  45678. }
  45679. declare module BABYLON {
  45680. /** @hidden */
  45681. export var backgroundUboDeclaration: {
  45682. name: string;
  45683. shader: string;
  45684. };
  45685. }
  45686. declare module BABYLON {
  45687. /** @hidden */
  45688. export var backgroundPixelShader: {
  45689. name: string;
  45690. shader: string;
  45691. };
  45692. }
  45693. declare module BABYLON {
  45694. /** @hidden */
  45695. export var backgroundVertexDeclaration: {
  45696. name: string;
  45697. shader: string;
  45698. };
  45699. }
  45700. declare module BABYLON {
  45701. /** @hidden */
  45702. export var backgroundVertexShader: {
  45703. name: string;
  45704. shader: string;
  45705. };
  45706. }
  45707. declare module BABYLON {
  45708. /**
  45709. * Background material used to create an efficient environement around your scene.
  45710. */
  45711. export class BackgroundMaterial extends PushMaterial {
  45712. /**
  45713. * Standard reflectance value at parallel view angle.
  45714. */
  45715. static StandardReflectance0: number;
  45716. /**
  45717. * Standard reflectance value at grazing angle.
  45718. */
  45719. static StandardReflectance90: number;
  45720. protected _primaryColor: Color3;
  45721. /**
  45722. * Key light Color (multiply against the environement texture)
  45723. */
  45724. primaryColor: Color3;
  45725. protected __perceptualColor: Nullable<Color3>;
  45726. /**
  45727. * Experimental Internal Use Only.
  45728. *
  45729. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45730. * This acts as a helper to set the primary color to a more "human friendly" value.
  45731. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45732. * output color as close as possible from the chosen value.
  45733. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45734. * part of lighting setup.)
  45735. */
  45736. _perceptualColor: Nullable<Color3>;
  45737. protected _primaryColorShadowLevel: float;
  45738. /**
  45739. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45740. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45741. */
  45742. primaryColorShadowLevel: float;
  45743. protected _primaryColorHighlightLevel: float;
  45744. /**
  45745. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45746. * The primary color is used at the level chosen to define what the white area would look.
  45747. */
  45748. primaryColorHighlightLevel: float;
  45749. protected _reflectionTexture: Nullable<BaseTexture>;
  45750. /**
  45751. * Reflection Texture used in the material.
  45752. * Should be author in a specific way for the best result (refer to the documentation).
  45753. */
  45754. reflectionTexture: Nullable<BaseTexture>;
  45755. protected _reflectionBlur: float;
  45756. /**
  45757. * Reflection Texture level of blur.
  45758. *
  45759. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45760. * texture twice.
  45761. */
  45762. reflectionBlur: float;
  45763. protected _diffuseTexture: Nullable<BaseTexture>;
  45764. /**
  45765. * Diffuse Texture used in the material.
  45766. * Should be author in a specific way for the best result (refer to the documentation).
  45767. */
  45768. diffuseTexture: Nullable<BaseTexture>;
  45769. protected _shadowLights: Nullable<IShadowLight[]>;
  45770. /**
  45771. * Specify the list of lights casting shadow on the material.
  45772. * All scene shadow lights will be included if null.
  45773. */
  45774. shadowLights: Nullable<IShadowLight[]>;
  45775. protected _shadowLevel: float;
  45776. /**
  45777. * Helps adjusting the shadow to a softer level if required.
  45778. * 0 means black shadows and 1 means no shadows.
  45779. */
  45780. shadowLevel: float;
  45781. protected _sceneCenter: Vector3;
  45782. /**
  45783. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45784. * It is usually zero but might be interesting to modify according to your setup.
  45785. */
  45786. sceneCenter: Vector3;
  45787. protected _opacityFresnel: boolean;
  45788. /**
  45789. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45790. * This helps ensuring a nice transition when the camera goes under the ground.
  45791. */
  45792. opacityFresnel: boolean;
  45793. protected _reflectionFresnel: boolean;
  45794. /**
  45795. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45796. * This helps adding a mirror texture on the ground.
  45797. */
  45798. reflectionFresnel: boolean;
  45799. protected _reflectionFalloffDistance: number;
  45800. /**
  45801. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45802. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45803. */
  45804. reflectionFalloffDistance: number;
  45805. protected _reflectionAmount: number;
  45806. /**
  45807. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45808. */
  45809. reflectionAmount: number;
  45810. protected _reflectionReflectance0: number;
  45811. /**
  45812. * This specifies the weight of the reflection at grazing angle.
  45813. */
  45814. reflectionReflectance0: number;
  45815. protected _reflectionReflectance90: number;
  45816. /**
  45817. * This specifies the weight of the reflection at a perpendicular point of view.
  45818. */
  45819. reflectionReflectance90: number;
  45820. /**
  45821. * Sets the reflection reflectance fresnel values according to the default standard
  45822. * empirically know to work well :-)
  45823. */
  45824. reflectionStandardFresnelWeight: number;
  45825. protected _useRGBColor: boolean;
  45826. /**
  45827. * Helps to directly use the maps channels instead of their level.
  45828. */
  45829. useRGBColor: boolean;
  45830. protected _enableNoise: boolean;
  45831. /**
  45832. * This helps reducing the banding effect that could occur on the background.
  45833. */
  45834. enableNoise: boolean;
  45835. /**
  45836. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45837. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45838. * Recommended to be keep at 1.0 except for special cases.
  45839. */
  45840. fovMultiplier: number;
  45841. private _fovMultiplier;
  45842. /**
  45843. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45844. */
  45845. useEquirectangularFOV: boolean;
  45846. private _maxSimultaneousLights;
  45847. /**
  45848. * Number of Simultaneous lights allowed on the material.
  45849. */
  45850. maxSimultaneousLights: int;
  45851. /**
  45852. * Default configuration related to image processing available in the Background Material.
  45853. */
  45854. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45855. /**
  45856. * Keep track of the image processing observer to allow dispose and replace.
  45857. */
  45858. private _imageProcessingObserver;
  45859. /**
  45860. * Attaches a new image processing configuration to the PBR Material.
  45861. * @param configuration (if null the scene configuration will be use)
  45862. */
  45863. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45864. /**
  45865. * Gets the image processing configuration used either in this material.
  45866. */
  45867. /**
  45868. * Sets the Default image processing configuration used either in the this material.
  45869. *
  45870. * If sets to null, the scene one is in use.
  45871. */
  45872. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45873. /**
  45874. * Gets wether the color curves effect is enabled.
  45875. */
  45876. /**
  45877. * Sets wether the color curves effect is enabled.
  45878. */
  45879. cameraColorCurvesEnabled: boolean;
  45880. /**
  45881. * Gets wether the color grading effect is enabled.
  45882. */
  45883. /**
  45884. * Gets wether the color grading effect is enabled.
  45885. */
  45886. cameraColorGradingEnabled: boolean;
  45887. /**
  45888. * Gets wether tonemapping is enabled or not.
  45889. */
  45890. /**
  45891. * Sets wether tonemapping is enabled or not
  45892. */
  45893. cameraToneMappingEnabled: boolean;
  45894. /**
  45895. * The camera exposure used on this material.
  45896. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45897. * This corresponds to a photographic exposure.
  45898. */
  45899. /**
  45900. * The camera exposure used on this material.
  45901. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45902. * This corresponds to a photographic exposure.
  45903. */
  45904. cameraExposure: float;
  45905. /**
  45906. * Gets The camera contrast used on this material.
  45907. */
  45908. /**
  45909. * Sets The camera contrast used on this material.
  45910. */
  45911. cameraContrast: float;
  45912. /**
  45913. * Gets the Color Grading 2D Lookup Texture.
  45914. */
  45915. /**
  45916. * Sets the Color Grading 2D Lookup Texture.
  45917. */
  45918. cameraColorGradingTexture: Nullable<BaseTexture>;
  45919. /**
  45920. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45921. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45922. * 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;
  45923. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45924. */
  45925. /**
  45926. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45927. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45928. * 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;
  45929. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45930. */
  45931. cameraColorCurves: Nullable<ColorCurves>;
  45932. /**
  45933. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45934. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45935. */
  45936. switchToBGR: boolean;
  45937. private _renderTargets;
  45938. private _reflectionControls;
  45939. private _white;
  45940. private _primaryShadowColor;
  45941. private _primaryHighlightColor;
  45942. /**
  45943. * Instantiates a Background Material in the given scene
  45944. * @param name The friendly name of the material
  45945. * @param scene The scene to add the material to
  45946. */
  45947. constructor(name: string, scene: Scene);
  45948. /**
  45949. * Gets a boolean indicating that current material needs to register RTT
  45950. */
  45951. readonly hasRenderTargetTextures: boolean;
  45952. /**
  45953. * The entire material has been created in order to prevent overdraw.
  45954. * @returns false
  45955. */
  45956. needAlphaTesting(): boolean;
  45957. /**
  45958. * The entire material has been created in order to prevent overdraw.
  45959. * @returns true if blending is enable
  45960. */
  45961. needAlphaBlending(): boolean;
  45962. /**
  45963. * Checks wether the material is ready to be rendered for a given mesh.
  45964. * @param mesh The mesh to render
  45965. * @param subMesh The submesh to check against
  45966. * @param useInstances Specify wether or not the material is used with instances
  45967. * @returns true if all the dependencies are ready (Textures, Effects...)
  45968. */
  45969. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45970. /**
  45971. * Compute the primary color according to the chosen perceptual color.
  45972. */
  45973. private _computePrimaryColorFromPerceptualColor;
  45974. /**
  45975. * Compute the highlights and shadow colors according to their chosen levels.
  45976. */
  45977. private _computePrimaryColors;
  45978. /**
  45979. * Build the uniform buffer used in the material.
  45980. */
  45981. buildUniformLayout(): void;
  45982. /**
  45983. * Unbind the material.
  45984. */
  45985. unbind(): void;
  45986. /**
  45987. * Bind only the world matrix to the material.
  45988. * @param world The world matrix to bind.
  45989. */
  45990. bindOnlyWorldMatrix(world: Matrix): void;
  45991. /**
  45992. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45993. * @param world The world matrix to bind.
  45994. * @param subMesh The submesh to bind for.
  45995. */
  45996. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45997. /**
  45998. * Checks to see if a texture is used in the material.
  45999. * @param texture - Base texture to use.
  46000. * @returns - Boolean specifying if a texture is used in the material.
  46001. */
  46002. hasTexture(texture: BaseTexture): boolean;
  46003. /**
  46004. * Dispose the material.
  46005. * @param forceDisposeEffect Force disposal of the associated effect.
  46006. * @param forceDisposeTextures Force disposal of the associated textures.
  46007. */
  46008. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46009. /**
  46010. * Clones the material.
  46011. * @param name The cloned name.
  46012. * @returns The cloned material.
  46013. */
  46014. clone(name: string): BackgroundMaterial;
  46015. /**
  46016. * Serializes the current material to its JSON representation.
  46017. * @returns The JSON representation.
  46018. */
  46019. serialize(): any;
  46020. /**
  46021. * Gets the class name of the material
  46022. * @returns "BackgroundMaterial"
  46023. */
  46024. getClassName(): string;
  46025. /**
  46026. * Parse a JSON input to create back a background material.
  46027. * @param source The JSON data to parse
  46028. * @param scene The scene to create the parsed material in
  46029. * @param rootUrl The root url of the assets the material depends upon
  46030. * @returns the instantiated BackgroundMaterial.
  46031. */
  46032. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46033. }
  46034. }
  46035. declare module BABYLON {
  46036. /**
  46037. * Represents the different options available during the creation of
  46038. * a Environment helper.
  46039. *
  46040. * This can control the default ground, skybox and image processing setup of your scene.
  46041. */
  46042. export interface IEnvironmentHelperOptions {
  46043. /**
  46044. * Specifies wether or not to create a ground.
  46045. * True by default.
  46046. */
  46047. createGround: boolean;
  46048. /**
  46049. * Specifies the ground size.
  46050. * 15 by default.
  46051. */
  46052. groundSize: number;
  46053. /**
  46054. * The texture used on the ground for the main color.
  46055. * Comes from the BabylonJS CDN by default.
  46056. *
  46057. * Remarks: Can be either a texture or a url.
  46058. */
  46059. groundTexture: string | BaseTexture;
  46060. /**
  46061. * The color mixed in the ground texture by default.
  46062. * BabylonJS clearColor by default.
  46063. */
  46064. groundColor: Color3;
  46065. /**
  46066. * Specifies the ground opacity.
  46067. * 1 by default.
  46068. */
  46069. groundOpacity: number;
  46070. /**
  46071. * Enables the ground to receive shadows.
  46072. * True by default.
  46073. */
  46074. enableGroundShadow: boolean;
  46075. /**
  46076. * Helps preventing the shadow to be fully black on the ground.
  46077. * 0.5 by default.
  46078. */
  46079. groundShadowLevel: number;
  46080. /**
  46081. * Creates a mirror texture attach to the ground.
  46082. * false by default.
  46083. */
  46084. enableGroundMirror: boolean;
  46085. /**
  46086. * Specifies the ground mirror size ratio.
  46087. * 0.3 by default as the default kernel is 64.
  46088. */
  46089. groundMirrorSizeRatio: number;
  46090. /**
  46091. * Specifies the ground mirror blur kernel size.
  46092. * 64 by default.
  46093. */
  46094. groundMirrorBlurKernel: number;
  46095. /**
  46096. * Specifies the ground mirror visibility amount.
  46097. * 1 by default
  46098. */
  46099. groundMirrorAmount: number;
  46100. /**
  46101. * Specifies the ground mirror reflectance weight.
  46102. * This uses the standard weight of the background material to setup the fresnel effect
  46103. * of the mirror.
  46104. * 1 by default.
  46105. */
  46106. groundMirrorFresnelWeight: number;
  46107. /**
  46108. * Specifies the ground mirror Falloff distance.
  46109. * This can helps reducing the size of the reflection.
  46110. * 0 by Default.
  46111. */
  46112. groundMirrorFallOffDistance: number;
  46113. /**
  46114. * Specifies the ground mirror texture type.
  46115. * Unsigned Int by Default.
  46116. */
  46117. groundMirrorTextureType: number;
  46118. /**
  46119. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46120. * the shown objects.
  46121. */
  46122. groundYBias: number;
  46123. /**
  46124. * Specifies wether or not to create a skybox.
  46125. * True by default.
  46126. */
  46127. createSkybox: boolean;
  46128. /**
  46129. * Specifies the skybox size.
  46130. * 20 by default.
  46131. */
  46132. skyboxSize: number;
  46133. /**
  46134. * The texture used on the skybox for the main color.
  46135. * Comes from the BabylonJS CDN by default.
  46136. *
  46137. * Remarks: Can be either a texture or a url.
  46138. */
  46139. skyboxTexture: string | BaseTexture;
  46140. /**
  46141. * The color mixed in the skybox texture by default.
  46142. * BabylonJS clearColor by default.
  46143. */
  46144. skyboxColor: Color3;
  46145. /**
  46146. * The background rotation around the Y axis of the scene.
  46147. * This helps aligning the key lights of your scene with the background.
  46148. * 0 by default.
  46149. */
  46150. backgroundYRotation: number;
  46151. /**
  46152. * Compute automatically the size of the elements to best fit with the scene.
  46153. */
  46154. sizeAuto: boolean;
  46155. /**
  46156. * Default position of the rootMesh if autoSize is not true.
  46157. */
  46158. rootPosition: Vector3;
  46159. /**
  46160. * Sets up the image processing in the scene.
  46161. * true by default.
  46162. */
  46163. setupImageProcessing: boolean;
  46164. /**
  46165. * The texture used as your environment texture in the scene.
  46166. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46167. *
  46168. * Remarks: Can be either a texture or a url.
  46169. */
  46170. environmentTexture: string | BaseTexture;
  46171. /**
  46172. * The value of the exposure to apply to the scene.
  46173. * 0.6 by default if setupImageProcessing is true.
  46174. */
  46175. cameraExposure: number;
  46176. /**
  46177. * The value of the contrast to apply to the scene.
  46178. * 1.6 by default if setupImageProcessing is true.
  46179. */
  46180. cameraContrast: number;
  46181. /**
  46182. * Specifies wether or not tonemapping should be enabled in the scene.
  46183. * true by default if setupImageProcessing is true.
  46184. */
  46185. toneMappingEnabled: boolean;
  46186. }
  46187. /**
  46188. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46189. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46190. * It also helps with the default setup of your imageProcessing configuration.
  46191. */
  46192. export class EnvironmentHelper {
  46193. /**
  46194. * Default ground texture URL.
  46195. */
  46196. private static _groundTextureCDNUrl;
  46197. /**
  46198. * Default skybox texture URL.
  46199. */
  46200. private static _skyboxTextureCDNUrl;
  46201. /**
  46202. * Default environment texture URL.
  46203. */
  46204. private static _environmentTextureCDNUrl;
  46205. /**
  46206. * Creates the default options for the helper.
  46207. */
  46208. private static _getDefaultOptions;
  46209. private _rootMesh;
  46210. /**
  46211. * Gets the root mesh created by the helper.
  46212. */
  46213. readonly rootMesh: Mesh;
  46214. private _skybox;
  46215. /**
  46216. * Gets the skybox created by the helper.
  46217. */
  46218. readonly skybox: Nullable<Mesh>;
  46219. private _skyboxTexture;
  46220. /**
  46221. * Gets the skybox texture created by the helper.
  46222. */
  46223. readonly skyboxTexture: Nullable<BaseTexture>;
  46224. private _skyboxMaterial;
  46225. /**
  46226. * Gets the skybox material created by the helper.
  46227. */
  46228. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46229. private _ground;
  46230. /**
  46231. * Gets the ground mesh created by the helper.
  46232. */
  46233. readonly ground: Nullable<Mesh>;
  46234. private _groundTexture;
  46235. /**
  46236. * Gets the ground texture created by the helper.
  46237. */
  46238. readonly groundTexture: Nullable<BaseTexture>;
  46239. private _groundMirror;
  46240. /**
  46241. * Gets the ground mirror created by the helper.
  46242. */
  46243. readonly groundMirror: Nullable<MirrorTexture>;
  46244. /**
  46245. * Gets the ground mirror render list to helps pushing the meshes
  46246. * you wish in the ground reflection.
  46247. */
  46248. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46249. private _groundMaterial;
  46250. /**
  46251. * Gets the ground material created by the helper.
  46252. */
  46253. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46254. /**
  46255. * Stores the creation options.
  46256. */
  46257. private readonly _scene;
  46258. private _options;
  46259. /**
  46260. * This observable will be notified with any error during the creation of the environment,
  46261. * mainly texture creation errors.
  46262. */
  46263. onErrorObservable: Observable<{
  46264. message?: string;
  46265. exception?: any;
  46266. }>;
  46267. /**
  46268. * constructor
  46269. * @param options Defines the options we want to customize the helper
  46270. * @param scene The scene to add the material to
  46271. */
  46272. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46273. /**
  46274. * Updates the background according to the new options
  46275. * @param options
  46276. */
  46277. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46278. /**
  46279. * Sets the primary color of all the available elements.
  46280. * @param color the main color to affect to the ground and the background
  46281. */
  46282. setMainColor(color: Color3): void;
  46283. /**
  46284. * Setup the image processing according to the specified options.
  46285. */
  46286. private _setupImageProcessing;
  46287. /**
  46288. * Setup the environment texture according to the specified options.
  46289. */
  46290. private _setupEnvironmentTexture;
  46291. /**
  46292. * Setup the background according to the specified options.
  46293. */
  46294. private _setupBackground;
  46295. /**
  46296. * Get the scene sizes according to the setup.
  46297. */
  46298. private _getSceneSize;
  46299. /**
  46300. * Setup the ground according to the specified options.
  46301. */
  46302. private _setupGround;
  46303. /**
  46304. * Setup the ground material according to the specified options.
  46305. */
  46306. private _setupGroundMaterial;
  46307. /**
  46308. * Setup the ground diffuse texture according to the specified options.
  46309. */
  46310. private _setupGroundDiffuseTexture;
  46311. /**
  46312. * Setup the ground mirror texture according to the specified options.
  46313. */
  46314. private _setupGroundMirrorTexture;
  46315. /**
  46316. * Setup the ground to receive the mirror texture.
  46317. */
  46318. private _setupMirrorInGroundMaterial;
  46319. /**
  46320. * Setup the skybox according to the specified options.
  46321. */
  46322. private _setupSkybox;
  46323. /**
  46324. * Setup the skybox material according to the specified options.
  46325. */
  46326. private _setupSkyboxMaterial;
  46327. /**
  46328. * Setup the skybox reflection texture according to the specified options.
  46329. */
  46330. private _setupSkyboxReflectionTexture;
  46331. private _errorHandler;
  46332. /**
  46333. * Dispose all the elements created by the Helper.
  46334. */
  46335. dispose(): void;
  46336. }
  46337. }
  46338. declare module BABYLON {
  46339. /**
  46340. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46341. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46342. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46343. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46344. */
  46345. export class PhotoDome extends TransformNode {
  46346. /**
  46347. * Define the image as a Monoscopic panoramic 360 image.
  46348. */
  46349. static readonly MODE_MONOSCOPIC: number;
  46350. /**
  46351. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46352. */
  46353. static readonly MODE_TOPBOTTOM: number;
  46354. /**
  46355. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46356. */
  46357. static readonly MODE_SIDEBYSIDE: number;
  46358. private _useDirectMapping;
  46359. /**
  46360. * The texture being displayed on the sphere
  46361. */
  46362. protected _photoTexture: Texture;
  46363. /**
  46364. * Gets or sets the texture being displayed on the sphere
  46365. */
  46366. photoTexture: Texture;
  46367. /**
  46368. * Observable raised when an error occured while loading the 360 image
  46369. */
  46370. onLoadErrorObservable: Observable<string>;
  46371. /**
  46372. * The skybox material
  46373. */
  46374. protected _material: BackgroundMaterial;
  46375. /**
  46376. * The surface used for the skybox
  46377. */
  46378. protected _mesh: Mesh;
  46379. /**
  46380. * Gets the mesh used for the skybox.
  46381. */
  46382. readonly mesh: Mesh;
  46383. /**
  46384. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46385. * Also see the options.resolution property.
  46386. */
  46387. fovMultiplier: number;
  46388. private _imageMode;
  46389. /**
  46390. * Gets or set the current video mode for the video. It can be:
  46391. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46392. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46393. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46394. */
  46395. imageMode: number;
  46396. /**
  46397. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46398. * @param name Element's name, child elements will append suffixes for their own names.
  46399. * @param urlsOfPhoto defines the url of the photo to display
  46400. * @param options defines an object containing optional or exposed sub element properties
  46401. * @param onError defines a callback called when an error occured while loading the texture
  46402. */
  46403. constructor(name: string, urlOfPhoto: string, options: {
  46404. resolution?: number;
  46405. size?: number;
  46406. useDirectMapping?: boolean;
  46407. faceForward?: boolean;
  46408. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46409. private _onBeforeCameraRenderObserver;
  46410. private _changeImageMode;
  46411. /**
  46412. * Releases resources associated with this node.
  46413. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46414. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46415. */
  46416. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46417. }
  46418. }
  46419. declare module BABYLON {
  46420. /**
  46421. * Class used to host RGBD texture specific utilities
  46422. */
  46423. export class RGBDTextureTools {
  46424. /**
  46425. * Expand the RGBD Texture from RGBD to Half Float if possible.
  46426. * @param texture the texture to expand.
  46427. */
  46428. static ExpandRGBDTexture(texture: Texture): void;
  46429. }
  46430. }
  46431. declare module BABYLON {
  46432. /**
  46433. * Class used to host texture specific utilities
  46434. */
  46435. export class BRDFTextureTools {
  46436. /**
  46437. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46438. * @param scene defines the hosting scene
  46439. * @returns the environment BRDF texture
  46440. */
  46441. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46442. private static _environmentBRDFBase64Texture;
  46443. }
  46444. }
  46445. declare module BABYLON {
  46446. /**
  46447. * @hidden
  46448. */
  46449. export interface IMaterialClearCoatDefines {
  46450. CLEARCOAT: boolean;
  46451. CLEARCOAT_DEFAULTIOR: boolean;
  46452. CLEARCOAT_TEXTURE: boolean;
  46453. CLEARCOAT_TEXTUREDIRECTUV: number;
  46454. CLEARCOAT_BUMP: boolean;
  46455. CLEARCOAT_BUMPDIRECTUV: number;
  46456. CLEARCOAT_TINT: boolean;
  46457. CLEARCOAT_TINT_TEXTURE: boolean;
  46458. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46459. /** @hidden */
  46460. _areTexturesDirty: boolean;
  46461. }
  46462. /**
  46463. * Define the code related to the clear coat parameters of the pbr material.
  46464. */
  46465. export class PBRClearCoatConfiguration {
  46466. /**
  46467. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46468. * The default fits with a polyurethane material.
  46469. */
  46470. private static readonly _DefaultIndexOfRefraction;
  46471. private _isEnabled;
  46472. /**
  46473. * Defines if the clear coat is enabled in the material.
  46474. */
  46475. isEnabled: boolean;
  46476. /**
  46477. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46478. */
  46479. intensity: number;
  46480. /**
  46481. * Defines the clear coat layer roughness.
  46482. */
  46483. roughness: number;
  46484. private _indexOfRefraction;
  46485. /**
  46486. * Defines the index of refraction of the clear coat.
  46487. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46488. * The default fits with a polyurethane material.
  46489. * Changing the default value is more performance intensive.
  46490. */
  46491. indexOfRefraction: number;
  46492. private _texture;
  46493. /**
  46494. * Stores the clear coat values in a texture.
  46495. */
  46496. texture: Nullable<BaseTexture>;
  46497. private _bumpTexture;
  46498. /**
  46499. * Define the clear coat specific bump texture.
  46500. */
  46501. bumpTexture: Nullable<BaseTexture>;
  46502. private _isTintEnabled;
  46503. /**
  46504. * Defines if the clear coat tint is enabled in the material.
  46505. */
  46506. isTintEnabled: boolean;
  46507. /**
  46508. * Defines the clear coat tint of the material.
  46509. * This is only use if tint is enabled
  46510. */
  46511. tintColor: Color3;
  46512. /**
  46513. * Defines the distance at which the tint color should be found in the
  46514. * clear coat media.
  46515. * This is only use if tint is enabled
  46516. */
  46517. tintColorAtDistance: number;
  46518. /**
  46519. * Defines the clear coat layer thickness.
  46520. * This is only use if tint is enabled
  46521. */
  46522. tintThickness: number;
  46523. private _tintTexture;
  46524. /**
  46525. * Stores the clear tint values in a texture.
  46526. * rgb is tint
  46527. * a is a thickness factor
  46528. */
  46529. tintTexture: Nullable<BaseTexture>;
  46530. /** @hidden */
  46531. private _internalMarkAllSubMeshesAsTexturesDirty;
  46532. /** @hidden */
  46533. _markAllSubMeshesAsTexturesDirty(): void;
  46534. /**
  46535. * Instantiate a new istance of clear coat configuration.
  46536. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46537. */
  46538. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46539. /**
  46540. * Gets wehter the submesh is ready to be used or not.
  46541. * @param defines the list of "defines" to update.
  46542. * @param scene defines the scene the material belongs to.
  46543. * @param engine defines the engine the material belongs to.
  46544. * @param disableBumpMap defines wether the material disables bump or not.
  46545. * @returns - boolean indicating that the submesh is ready or not.
  46546. */
  46547. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46548. /**
  46549. * Checks to see if a texture is used in the material.
  46550. * @param defines the list of "defines" to update.
  46551. * @param scene defines the scene to the material belongs to.
  46552. */
  46553. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46554. /**
  46555. * Binds the material data.
  46556. * @param uniformBuffer defines the Uniform buffer to fill in.
  46557. * @param scene defines the scene the material belongs to.
  46558. * @param engine defines the engine the material belongs to.
  46559. * @param disableBumpMap defines wether the material disables bump or not.
  46560. * @param isFrozen defines wether the material is frozen or not.
  46561. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46562. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46563. */
  46564. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46565. /**
  46566. * Checks to see if a texture is used in the material.
  46567. * @param texture - Base texture to use.
  46568. * @returns - Boolean specifying if a texture is used in the material.
  46569. */
  46570. hasTexture(texture: BaseTexture): boolean;
  46571. /**
  46572. * Returns an array of the actively used textures.
  46573. * @param activeTextures Array of BaseTextures
  46574. */
  46575. getActiveTextures(activeTextures: BaseTexture[]): void;
  46576. /**
  46577. * Returns the animatable textures.
  46578. * @param animatables Array of animatable textures.
  46579. */
  46580. getAnimatables(animatables: IAnimatable[]): void;
  46581. /**
  46582. * Disposes the resources of the material.
  46583. * @param forceDisposeTextures - Forces the disposal of all textures.
  46584. */
  46585. dispose(forceDisposeTextures?: boolean): void;
  46586. /**
  46587. * Get the current class name of the texture useful for serialization or dynamic coding.
  46588. * @returns "PBRClearCoatConfiguration"
  46589. */
  46590. getClassName(): string;
  46591. /**
  46592. * Add fallbacks to the effect fallbacks list.
  46593. * @param defines defines the Base texture to use.
  46594. * @param fallbacks defines the current fallback list.
  46595. * @param currentRank defines the current fallback rank.
  46596. * @returns the new fallback rank.
  46597. */
  46598. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46599. /**
  46600. * Add the required uniforms to the current list.
  46601. * @param uniforms defines the current uniform list.
  46602. */
  46603. static AddUniforms(uniforms: string[]): void;
  46604. /**
  46605. * Add the required samplers to the current list.
  46606. * @param samplers defines the current sampler list.
  46607. */
  46608. static AddSamplers(samplers: string[]): void;
  46609. /**
  46610. * Add the required uniforms to the current buffer.
  46611. * @param uniformBuffer defines the current uniform buffer.
  46612. */
  46613. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46614. /**
  46615. * Makes a duplicate of the current configuration into another one.
  46616. * @param clearCoatConfiguration define the config where to copy the info
  46617. */
  46618. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46619. /**
  46620. * Serializes this clear coat configuration.
  46621. * @returns - An object with the serialized config.
  46622. */
  46623. serialize(): any;
  46624. /**
  46625. * Parses a anisotropy Configuration from a serialized object.
  46626. * @param source - Serialized object.
  46627. * @param scene Defines the scene we are parsing for
  46628. * @param rootUrl Defines the rootUrl to load from
  46629. */
  46630. parse(source: any, scene: Scene, rootUrl: string): void;
  46631. }
  46632. }
  46633. declare module BABYLON {
  46634. /**
  46635. * @hidden
  46636. */
  46637. export interface IMaterialAnisotropicDefines {
  46638. ANISOTROPIC: boolean;
  46639. ANISOTROPIC_TEXTURE: boolean;
  46640. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46641. MAINUV1: boolean;
  46642. _areTexturesDirty: boolean;
  46643. _needUVs: boolean;
  46644. }
  46645. /**
  46646. * Define the code related to the anisotropic parameters of the pbr material.
  46647. */
  46648. export class PBRAnisotropicConfiguration {
  46649. private _isEnabled;
  46650. /**
  46651. * Defines if the anisotropy is enabled in the material.
  46652. */
  46653. isEnabled: boolean;
  46654. /**
  46655. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46656. */
  46657. intensity: number;
  46658. /**
  46659. * Defines if the effect is along the tangents, bitangents or in between.
  46660. * By default, the effect is "strectching" the highlights along the tangents.
  46661. */
  46662. direction: Vector2;
  46663. private _texture;
  46664. /**
  46665. * Stores the anisotropy values in a texture.
  46666. * rg is direction (like normal from -1 to 1)
  46667. * b is a intensity
  46668. */
  46669. texture: Nullable<BaseTexture>;
  46670. /** @hidden */
  46671. private _internalMarkAllSubMeshesAsTexturesDirty;
  46672. /** @hidden */
  46673. _markAllSubMeshesAsTexturesDirty(): void;
  46674. /**
  46675. * Instantiate a new istance of anisotropy configuration.
  46676. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46677. */
  46678. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46679. /**
  46680. * Specifies that the submesh is ready to be used.
  46681. * @param defines the list of "defines" to update.
  46682. * @param scene defines the scene the material belongs to.
  46683. * @returns - boolean indicating that the submesh is ready or not.
  46684. */
  46685. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46686. /**
  46687. * Checks to see if a texture is used in the material.
  46688. * @param defines the list of "defines" to update.
  46689. * @param mesh the mesh we are preparing the defines for.
  46690. * @param scene defines the scene the material belongs to.
  46691. */
  46692. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46693. /**
  46694. * Binds the material data.
  46695. * @param uniformBuffer defines the Uniform buffer to fill in.
  46696. * @param scene defines the scene the material belongs to.
  46697. * @param isFrozen defines wether the material is frozen or not.
  46698. */
  46699. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46700. /**
  46701. * Checks to see if a texture is used in the material.
  46702. * @param texture - Base texture to use.
  46703. * @returns - Boolean specifying if a texture is used in the material.
  46704. */
  46705. hasTexture(texture: BaseTexture): boolean;
  46706. /**
  46707. * Returns an array of the actively used textures.
  46708. * @param activeTextures Array of BaseTextures
  46709. */
  46710. getActiveTextures(activeTextures: BaseTexture[]): void;
  46711. /**
  46712. * Returns the animatable textures.
  46713. * @param animatables Array of animatable textures.
  46714. */
  46715. getAnimatables(animatables: IAnimatable[]): void;
  46716. /**
  46717. * Disposes the resources of the material.
  46718. * @param forceDisposeTextures - Forces the disposal of all textures.
  46719. */
  46720. dispose(forceDisposeTextures?: boolean): void;
  46721. /**
  46722. * Get the current class name of the texture useful for serialization or dynamic coding.
  46723. * @returns "PBRAnisotropicConfiguration"
  46724. */
  46725. getClassName(): string;
  46726. /**
  46727. * Add fallbacks to the effect fallbacks list.
  46728. * @param defines defines the Base texture to use.
  46729. * @param fallbacks defines the current fallback list.
  46730. * @param currentRank defines the current fallback rank.
  46731. * @returns the new fallback rank.
  46732. */
  46733. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46734. /**
  46735. * Add the required uniforms to the current list.
  46736. * @param uniforms defines the current uniform list.
  46737. */
  46738. static AddUniforms(uniforms: string[]): void;
  46739. /**
  46740. * Add the required uniforms to the current buffer.
  46741. * @param uniformBuffer defines the current uniform buffer.
  46742. */
  46743. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46744. /**
  46745. * Add the required samplers to the current list.
  46746. * @param samplers defines the current sampler list.
  46747. */
  46748. static AddSamplers(samplers: string[]): void;
  46749. /**
  46750. * Makes a duplicate of the current configuration into another one.
  46751. * @param anisotropicConfiguration define the config where to copy the info
  46752. */
  46753. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46754. /**
  46755. * Serializes this anisotropy configuration.
  46756. * @returns - An object with the serialized config.
  46757. */
  46758. serialize(): any;
  46759. /**
  46760. * Parses a anisotropy Configuration from a serialized object.
  46761. * @param source - Serialized object.
  46762. * @param scene Defines the scene we are parsing for
  46763. * @param rootUrl Defines the rootUrl to load from
  46764. */
  46765. parse(source: any, scene: Scene, rootUrl: string): void;
  46766. }
  46767. }
  46768. declare module BABYLON {
  46769. /**
  46770. * @hidden
  46771. */
  46772. export interface IMaterialBRDFDefines {
  46773. BRDF_V_HEIGHT_CORRELATED: boolean;
  46774. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46775. SPHERICAL_HARMONICS: boolean;
  46776. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46777. /** @hidden */
  46778. _areMiscDirty: boolean;
  46779. }
  46780. /**
  46781. * Define the code related to the BRDF parameters of the pbr material.
  46782. */
  46783. export class PBRBRDFConfiguration {
  46784. /**
  46785. * Default value used for the energy conservation.
  46786. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46787. */
  46788. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46789. /**
  46790. * Default value used for the Smith Visibility Height Correlated mode.
  46791. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46792. */
  46793. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46794. /**
  46795. * Default value used for the IBL diffuse part.
  46796. * This can help switching back to the polynomials mode globally which is a tiny bit
  46797. * less GPU intensive at the drawback of a lower quality.
  46798. */
  46799. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46800. /**
  46801. * Default value used for activating energy conservation for the specular workflow.
  46802. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46803. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46804. */
  46805. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  46806. private _useEnergyConservation;
  46807. /**
  46808. * Defines if the material uses energy conservation.
  46809. */
  46810. useEnergyConservation: boolean;
  46811. private _useSmithVisibilityHeightCorrelated;
  46812. /**
  46813. * LEGACY Mode set to false
  46814. * Defines if the material uses height smith correlated visibility term.
  46815. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46816. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46817. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46818. * Not relying on height correlated will also disable energy conservation.
  46819. */
  46820. useSmithVisibilityHeightCorrelated: boolean;
  46821. private _useSphericalHarmonics;
  46822. /**
  46823. * LEGACY Mode set to false
  46824. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46825. * diffuse part of the IBL.
  46826. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46827. * to the ground truth.
  46828. */
  46829. useSphericalHarmonics: boolean;
  46830. private _useSpecularGlossinessInputEnergyConservation;
  46831. /**
  46832. * Defines if the material uses energy conservation, when the specular workflow is active.
  46833. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46834. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46835. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46836. */
  46837. useSpecularGlossinessInputEnergyConservation: boolean;
  46838. /** @hidden */
  46839. private _internalMarkAllSubMeshesAsMiscDirty;
  46840. /** @hidden */
  46841. _markAllSubMeshesAsMiscDirty(): void;
  46842. /**
  46843. * Instantiate a new istance of clear coat configuration.
  46844. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46845. */
  46846. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46847. /**
  46848. * Checks to see if a texture is used in the material.
  46849. * @param defines the list of "defines" to update.
  46850. */
  46851. prepareDefines(defines: IMaterialBRDFDefines): void;
  46852. /**
  46853. * Get the current class name of the texture useful for serialization or dynamic coding.
  46854. * @returns "PBRClearCoatConfiguration"
  46855. */
  46856. getClassName(): string;
  46857. /**
  46858. * Makes a duplicate of the current configuration into another one.
  46859. * @param brdfConfiguration define the config where to copy the info
  46860. */
  46861. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46862. /**
  46863. * Serializes this BRDF configuration.
  46864. * @returns - An object with the serialized config.
  46865. */
  46866. serialize(): any;
  46867. /**
  46868. * Parses a anisotropy Configuration from a serialized object.
  46869. * @param source - Serialized object.
  46870. * @param scene Defines the scene we are parsing for
  46871. * @param rootUrl Defines the rootUrl to load from
  46872. */
  46873. parse(source: any, scene: Scene, rootUrl: string): void;
  46874. }
  46875. }
  46876. declare module BABYLON {
  46877. /**
  46878. * @hidden
  46879. */
  46880. export interface IMaterialSheenDefines {
  46881. SHEEN: boolean;
  46882. SHEEN_TEXTURE: boolean;
  46883. SHEEN_TEXTUREDIRECTUV: number;
  46884. SHEEN_LINKWITHALBEDO: boolean;
  46885. /** @hidden */
  46886. _areTexturesDirty: boolean;
  46887. }
  46888. /**
  46889. * Define the code related to the Sheen parameters of the pbr material.
  46890. */
  46891. export class PBRSheenConfiguration {
  46892. private _isEnabled;
  46893. /**
  46894. * Defines if the material uses sheen.
  46895. */
  46896. isEnabled: boolean;
  46897. private _linkSheenWithAlbedo;
  46898. /**
  46899. * Defines if the sheen is linked to the sheen color.
  46900. */
  46901. linkSheenWithAlbedo: boolean;
  46902. /**
  46903. * Defines the sheen intensity.
  46904. */
  46905. intensity: number;
  46906. /**
  46907. * Defines the sheen color.
  46908. */
  46909. color: Color3;
  46910. private _texture;
  46911. /**
  46912. * Stores the sheen tint values in a texture.
  46913. * rgb is tint
  46914. * a is a intensity
  46915. */
  46916. texture: Nullable<BaseTexture>;
  46917. /** @hidden */
  46918. private _internalMarkAllSubMeshesAsTexturesDirty;
  46919. /** @hidden */
  46920. _markAllSubMeshesAsTexturesDirty(): void;
  46921. /**
  46922. * Instantiate a new istance of clear coat configuration.
  46923. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46924. */
  46925. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46926. /**
  46927. * Specifies that the submesh is ready to be used.
  46928. * @param defines the list of "defines" to update.
  46929. * @param scene defines the scene the material belongs to.
  46930. * @returns - boolean indicating that the submesh is ready or not.
  46931. */
  46932. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46933. /**
  46934. * Checks to see if a texture is used in the material.
  46935. * @param defines the list of "defines" to update.
  46936. * @param scene defines the scene the material belongs to.
  46937. */
  46938. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46939. /**
  46940. * Binds the material data.
  46941. * @param uniformBuffer defines the Uniform buffer to fill in.
  46942. * @param scene defines the scene the material belongs to.
  46943. * @param isFrozen defines wether the material is frozen or not.
  46944. */
  46945. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46946. /**
  46947. * Checks to see if a texture is used in the material.
  46948. * @param texture - Base texture to use.
  46949. * @returns - Boolean specifying if a texture is used in the material.
  46950. */
  46951. hasTexture(texture: BaseTexture): boolean;
  46952. /**
  46953. * Returns an array of the actively used textures.
  46954. * @param activeTextures Array of BaseTextures
  46955. */
  46956. getActiveTextures(activeTextures: BaseTexture[]): void;
  46957. /**
  46958. * Returns the animatable textures.
  46959. * @param animatables Array of animatable textures.
  46960. */
  46961. getAnimatables(animatables: IAnimatable[]): void;
  46962. /**
  46963. * Disposes the resources of the material.
  46964. * @param forceDisposeTextures - Forces the disposal of all textures.
  46965. */
  46966. dispose(forceDisposeTextures?: boolean): void;
  46967. /**
  46968. * Get the current class name of the texture useful for serialization or dynamic coding.
  46969. * @returns "PBRSheenConfiguration"
  46970. */
  46971. getClassName(): string;
  46972. /**
  46973. * Add fallbacks to the effect fallbacks list.
  46974. * @param defines defines the Base texture to use.
  46975. * @param fallbacks defines the current fallback list.
  46976. * @param currentRank defines the current fallback rank.
  46977. * @returns the new fallback rank.
  46978. */
  46979. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46980. /**
  46981. * Add the required uniforms to the current list.
  46982. * @param uniforms defines the current uniform list.
  46983. */
  46984. static AddUniforms(uniforms: string[]): void;
  46985. /**
  46986. * Add the required uniforms to the current buffer.
  46987. * @param uniformBuffer defines the current uniform buffer.
  46988. */
  46989. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46990. /**
  46991. * Add the required samplers to the current list.
  46992. * @param samplers defines the current sampler list.
  46993. */
  46994. static AddSamplers(samplers: string[]): void;
  46995. /**
  46996. * Makes a duplicate of the current configuration into another one.
  46997. * @param sheenConfiguration define the config where to copy the info
  46998. */
  46999. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47000. /**
  47001. * Serializes this BRDF configuration.
  47002. * @returns - An object with the serialized config.
  47003. */
  47004. serialize(): any;
  47005. /**
  47006. * Parses a anisotropy Configuration from a serialized object.
  47007. * @param source - Serialized object.
  47008. * @param scene Defines the scene we are parsing for
  47009. * @param rootUrl Defines the rootUrl to load from
  47010. */
  47011. parse(source: any, scene: Scene, rootUrl: string): void;
  47012. }
  47013. }
  47014. declare module BABYLON {
  47015. /**
  47016. * @hidden
  47017. */
  47018. export interface IMaterialSubSurfaceDefines {
  47019. SUBSURFACE: boolean;
  47020. SS_REFRACTION: boolean;
  47021. SS_TRANSLUCENCY: boolean;
  47022. SS_SCATERRING: boolean;
  47023. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47024. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47025. SS_REFRACTIONMAP_3D: boolean;
  47026. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47027. SS_LODINREFRACTIONALPHA: boolean;
  47028. SS_GAMMAREFRACTION: boolean;
  47029. SS_RGBDREFRACTION: boolean;
  47030. SS_LINEARSPECULARREFRACTION: boolean;
  47031. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47032. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47033. /** @hidden */
  47034. _areTexturesDirty: boolean;
  47035. }
  47036. /**
  47037. * Define the code related to the sub surface parameters of the pbr material.
  47038. */
  47039. export class PBRSubSurfaceConfiguration {
  47040. private _isRefractionEnabled;
  47041. /**
  47042. * Defines if the refraction is enabled in the material.
  47043. */
  47044. isRefractionEnabled: boolean;
  47045. private _isTranslucencyEnabled;
  47046. /**
  47047. * Defines if the translucency is enabled in the material.
  47048. */
  47049. isTranslucencyEnabled: boolean;
  47050. private _isScatteringEnabled;
  47051. /**
  47052. * Defines the refraction intensity of the material.
  47053. * The refraction when enabled replaces the Diffuse part of the material.
  47054. * The intensity helps transitionning between diffuse and refraction.
  47055. */
  47056. refractionIntensity: number;
  47057. /**
  47058. * Defines the translucency intensity of the material.
  47059. * When translucency has been enabled, this defines how much of the "translucency"
  47060. * is addded to the diffuse part of the material.
  47061. */
  47062. translucencyIntensity: number;
  47063. /**
  47064. * Defines the scattering intensity of the material.
  47065. * When scattering has been enabled, this defines how much of the "scattered light"
  47066. * is addded to the diffuse part of the material.
  47067. */
  47068. scatteringIntensity: number;
  47069. private _thicknessTexture;
  47070. /**
  47071. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47072. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47073. * 0 would mean minimumThickness
  47074. * 1 would mean maximumThickness
  47075. * The other channels might be use as a mask to vary the different effects intensity.
  47076. */
  47077. thicknessTexture: Nullable<BaseTexture>;
  47078. private _refractionTexture;
  47079. /**
  47080. * Defines the texture to use for refraction.
  47081. */
  47082. refractionTexture: Nullable<BaseTexture>;
  47083. private _indexOfRefraction;
  47084. /**
  47085. * Defines the index of refraction used in the material.
  47086. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47087. */
  47088. indexOfRefraction: number;
  47089. private _invertRefractionY;
  47090. /**
  47091. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47092. */
  47093. invertRefractionY: boolean;
  47094. private _linkRefractionWithTransparency;
  47095. /**
  47096. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47097. * Materials half opaque for instance using refraction could benefit from this control.
  47098. */
  47099. linkRefractionWithTransparency: boolean;
  47100. /**
  47101. * Defines the minimum thickness stored in the thickness map.
  47102. * If no thickness map is defined, this value will be used to simulate thickness.
  47103. */
  47104. minimumThickness: number;
  47105. /**
  47106. * Defines the maximum thickness stored in the thickness map.
  47107. */
  47108. maximumThickness: number;
  47109. /**
  47110. * Defines the volume tint of the material.
  47111. * This is used for both translucency and scattering.
  47112. */
  47113. tintColor: Color3;
  47114. /**
  47115. * Defines the distance at which the tint color should be found in the media.
  47116. * This is used for refraction only.
  47117. */
  47118. tintColorAtDistance: number;
  47119. /**
  47120. * Defines how far each channel transmit through the media.
  47121. * It is defined as a color to simplify it selection.
  47122. */
  47123. diffusionDistance: Color3;
  47124. private _useMaskFromThicknessTexture;
  47125. /**
  47126. * Stores the intensity of the different subsurface effects in the thickness texture.
  47127. * * the green channel is the translucency intensity.
  47128. * * the blue channel is the scattering intensity.
  47129. * * the alpha channel is the refraction intensity.
  47130. */
  47131. useMaskFromThicknessTexture: boolean;
  47132. /** @hidden */
  47133. private _internalMarkAllSubMeshesAsTexturesDirty;
  47134. /** @hidden */
  47135. _markAllSubMeshesAsTexturesDirty(): void;
  47136. /**
  47137. * Instantiate a new istance of sub surface configuration.
  47138. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47139. */
  47140. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47141. /**
  47142. * Gets wehter the submesh is ready to be used or not.
  47143. * @param defines the list of "defines" to update.
  47144. * @param scene defines the scene the material belongs to.
  47145. * @returns - boolean indicating that the submesh is ready or not.
  47146. */
  47147. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47148. /**
  47149. * Checks to see if a texture is used in the material.
  47150. * @param defines the list of "defines" to update.
  47151. * @param scene defines the scene to the material belongs to.
  47152. */
  47153. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47154. /**
  47155. * Binds the material data.
  47156. * @param uniformBuffer defines the Uniform buffer to fill in.
  47157. * @param scene defines the scene the material belongs to.
  47158. * @param engine defines the engine the material belongs to.
  47159. * @param isFrozen defines wether the material is frozen or not.
  47160. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47161. */
  47162. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47163. /**
  47164. * Unbinds the material from the mesh.
  47165. * @param activeEffect defines the effect that should be unbound from.
  47166. * @returns true if unbound, otherwise false
  47167. */
  47168. unbind(activeEffect: Effect): boolean;
  47169. /**
  47170. * Returns the texture used for refraction or null if none is used.
  47171. * @param scene defines the scene the material belongs to.
  47172. * @returns - Refraction texture if present. If no refraction texture and refraction
  47173. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47174. */
  47175. private _getRefractionTexture;
  47176. /**
  47177. * Returns true if alpha blending should be disabled.
  47178. */
  47179. readonly disableAlphaBlending: boolean;
  47180. /**
  47181. * Fills the list of render target textures.
  47182. * @param renderTargets the list of render targets to update
  47183. */
  47184. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47185. /**
  47186. * Checks to see if a texture is used in the material.
  47187. * @param texture - Base texture to use.
  47188. * @returns - Boolean specifying if a texture is used in the material.
  47189. */
  47190. hasTexture(texture: BaseTexture): boolean;
  47191. /**
  47192. * Gets a boolean indicating that current material needs to register RTT
  47193. * @returns true if this uses a render target otherwise false.
  47194. */
  47195. hasRenderTargetTextures(): boolean;
  47196. /**
  47197. * Returns an array of the actively used textures.
  47198. * @param activeTextures Array of BaseTextures
  47199. */
  47200. getActiveTextures(activeTextures: BaseTexture[]): void;
  47201. /**
  47202. * Returns the animatable textures.
  47203. * @param animatables Array of animatable textures.
  47204. */
  47205. getAnimatables(animatables: IAnimatable[]): void;
  47206. /**
  47207. * Disposes the resources of the material.
  47208. * @param forceDisposeTextures - Forces the disposal of all textures.
  47209. */
  47210. dispose(forceDisposeTextures?: boolean): void;
  47211. /**
  47212. * Get the current class name of the texture useful for serialization or dynamic coding.
  47213. * @returns "PBRSubSurfaceConfiguration"
  47214. */
  47215. getClassName(): string;
  47216. /**
  47217. * Add fallbacks to the effect fallbacks list.
  47218. * @param defines defines the Base texture to use.
  47219. * @param fallbacks defines the current fallback list.
  47220. * @param currentRank defines the current fallback rank.
  47221. * @returns the new fallback rank.
  47222. */
  47223. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47224. /**
  47225. * Add the required uniforms to the current list.
  47226. * @param uniforms defines the current uniform list.
  47227. */
  47228. static AddUniforms(uniforms: string[]): void;
  47229. /**
  47230. * Add the required samplers to the current list.
  47231. * @param samplers defines the current sampler list.
  47232. */
  47233. static AddSamplers(samplers: string[]): void;
  47234. /**
  47235. * Add the required uniforms to the current buffer.
  47236. * @param uniformBuffer defines the current uniform buffer.
  47237. */
  47238. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47239. /**
  47240. * Makes a duplicate of the current configuration into another one.
  47241. * @param configuration define the config where to copy the info
  47242. */
  47243. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47244. /**
  47245. * Serializes this Sub Surface configuration.
  47246. * @returns - An object with the serialized config.
  47247. */
  47248. serialize(): any;
  47249. /**
  47250. * Parses a anisotropy Configuration from a serialized object.
  47251. * @param source - Serialized object.
  47252. * @param scene Defines the scene we are parsing for
  47253. * @param rootUrl Defines the rootUrl to load from
  47254. */
  47255. parse(source: any, scene: Scene, rootUrl: string): void;
  47256. }
  47257. }
  47258. declare module BABYLON {
  47259. /** @hidden */
  47260. export var pbrFragmentDeclaration: {
  47261. name: string;
  47262. shader: string;
  47263. };
  47264. }
  47265. declare module BABYLON {
  47266. /** @hidden */
  47267. export var pbrUboDeclaration: {
  47268. name: string;
  47269. shader: string;
  47270. };
  47271. }
  47272. declare module BABYLON {
  47273. /** @hidden */
  47274. export var pbrFragmentExtraDeclaration: {
  47275. name: string;
  47276. shader: string;
  47277. };
  47278. }
  47279. declare module BABYLON {
  47280. /** @hidden */
  47281. export var pbrFragmentSamplersDeclaration: {
  47282. name: string;
  47283. shader: string;
  47284. };
  47285. }
  47286. declare module BABYLON {
  47287. /** @hidden */
  47288. export var pbrHelperFunctions: {
  47289. name: string;
  47290. shader: string;
  47291. };
  47292. }
  47293. declare module BABYLON {
  47294. /** @hidden */
  47295. export var harmonicsFunctions: {
  47296. name: string;
  47297. shader: string;
  47298. };
  47299. }
  47300. declare module BABYLON {
  47301. /** @hidden */
  47302. export var pbrDirectLightingSetupFunctions: {
  47303. name: string;
  47304. shader: string;
  47305. };
  47306. }
  47307. declare module BABYLON {
  47308. /** @hidden */
  47309. export var pbrDirectLightingFalloffFunctions: {
  47310. name: string;
  47311. shader: string;
  47312. };
  47313. }
  47314. declare module BABYLON {
  47315. /** @hidden */
  47316. export var pbrBRDFFunctions: {
  47317. name: string;
  47318. shader: string;
  47319. };
  47320. }
  47321. declare module BABYLON {
  47322. /** @hidden */
  47323. export var pbrDirectLightingFunctions: {
  47324. name: string;
  47325. shader: string;
  47326. };
  47327. }
  47328. declare module BABYLON {
  47329. /** @hidden */
  47330. export var pbrIBLFunctions: {
  47331. name: string;
  47332. shader: string;
  47333. };
  47334. }
  47335. declare module BABYLON {
  47336. /** @hidden */
  47337. export var pbrDebug: {
  47338. name: string;
  47339. shader: string;
  47340. };
  47341. }
  47342. declare module BABYLON {
  47343. /** @hidden */
  47344. export var pbrPixelShader: {
  47345. name: string;
  47346. shader: string;
  47347. };
  47348. }
  47349. declare module BABYLON {
  47350. /** @hidden */
  47351. export var pbrVertexDeclaration: {
  47352. name: string;
  47353. shader: string;
  47354. };
  47355. }
  47356. declare module BABYLON {
  47357. /** @hidden */
  47358. export var pbrVertexShader: {
  47359. name: string;
  47360. shader: string;
  47361. };
  47362. }
  47363. declare module BABYLON {
  47364. /**
  47365. * Manages the defines for the PBR Material.
  47366. * @hidden
  47367. */
  47368. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47369. PBR: boolean;
  47370. MAINUV1: boolean;
  47371. MAINUV2: boolean;
  47372. UV1: boolean;
  47373. UV2: boolean;
  47374. ALBEDO: boolean;
  47375. ALBEDODIRECTUV: number;
  47376. VERTEXCOLOR: boolean;
  47377. AMBIENT: boolean;
  47378. AMBIENTDIRECTUV: number;
  47379. AMBIENTINGRAYSCALE: boolean;
  47380. OPACITY: boolean;
  47381. VERTEXALPHA: boolean;
  47382. OPACITYDIRECTUV: number;
  47383. OPACITYRGB: boolean;
  47384. ALPHATEST: boolean;
  47385. DEPTHPREPASS: boolean;
  47386. ALPHABLEND: boolean;
  47387. ALPHAFROMALBEDO: boolean;
  47388. ALPHATESTVALUE: string;
  47389. SPECULAROVERALPHA: boolean;
  47390. RADIANCEOVERALPHA: boolean;
  47391. ALPHAFRESNEL: boolean;
  47392. LINEARALPHAFRESNEL: boolean;
  47393. PREMULTIPLYALPHA: boolean;
  47394. EMISSIVE: boolean;
  47395. EMISSIVEDIRECTUV: number;
  47396. REFLECTIVITY: boolean;
  47397. REFLECTIVITYDIRECTUV: number;
  47398. SPECULARTERM: boolean;
  47399. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47400. MICROSURFACEAUTOMATIC: boolean;
  47401. LODBASEDMICROSFURACE: boolean;
  47402. MICROSURFACEMAP: boolean;
  47403. MICROSURFACEMAPDIRECTUV: number;
  47404. METALLICWORKFLOW: boolean;
  47405. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47406. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47407. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47408. AOSTOREINMETALMAPRED: boolean;
  47409. ENVIRONMENTBRDF: boolean;
  47410. ENVIRONMENTBRDF_RGBD: boolean;
  47411. NORMAL: boolean;
  47412. TANGENT: boolean;
  47413. BUMP: boolean;
  47414. BUMPDIRECTUV: number;
  47415. OBJECTSPACE_NORMALMAP: boolean;
  47416. PARALLAX: boolean;
  47417. PARALLAXOCCLUSION: boolean;
  47418. NORMALXYSCALE: boolean;
  47419. LIGHTMAP: boolean;
  47420. LIGHTMAPDIRECTUV: number;
  47421. USELIGHTMAPASSHADOWMAP: boolean;
  47422. GAMMALIGHTMAP: boolean;
  47423. RGBDLIGHTMAP: boolean;
  47424. REFLECTION: boolean;
  47425. REFLECTIONMAP_3D: boolean;
  47426. REFLECTIONMAP_SPHERICAL: boolean;
  47427. REFLECTIONMAP_PLANAR: boolean;
  47428. REFLECTIONMAP_CUBIC: boolean;
  47429. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47430. REFLECTIONMAP_PROJECTION: boolean;
  47431. REFLECTIONMAP_SKYBOX: boolean;
  47432. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47433. REFLECTIONMAP_EXPLICIT: boolean;
  47434. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47435. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47436. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47437. INVERTCUBICMAP: boolean;
  47438. USESPHERICALFROMREFLECTIONMAP: boolean;
  47439. USEIRRADIANCEMAP: boolean;
  47440. SPHERICAL_HARMONICS: boolean;
  47441. USESPHERICALINVERTEX: boolean;
  47442. REFLECTIONMAP_OPPOSITEZ: boolean;
  47443. LODINREFLECTIONALPHA: boolean;
  47444. GAMMAREFLECTION: boolean;
  47445. RGBDREFLECTION: boolean;
  47446. LINEARSPECULARREFLECTION: boolean;
  47447. RADIANCEOCCLUSION: boolean;
  47448. HORIZONOCCLUSION: boolean;
  47449. INSTANCES: boolean;
  47450. NUM_BONE_INFLUENCERS: number;
  47451. BonesPerMesh: number;
  47452. BONETEXTURE: boolean;
  47453. NONUNIFORMSCALING: boolean;
  47454. MORPHTARGETS: boolean;
  47455. MORPHTARGETS_NORMAL: boolean;
  47456. MORPHTARGETS_TANGENT: boolean;
  47457. MORPHTARGETS_UV: boolean;
  47458. NUM_MORPH_INFLUENCERS: number;
  47459. IMAGEPROCESSING: boolean;
  47460. VIGNETTE: boolean;
  47461. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47462. VIGNETTEBLENDMODEOPAQUE: boolean;
  47463. TONEMAPPING: boolean;
  47464. TONEMAPPING_ACES: boolean;
  47465. CONTRAST: boolean;
  47466. COLORCURVES: boolean;
  47467. COLORGRADING: boolean;
  47468. COLORGRADING3D: boolean;
  47469. SAMPLER3DGREENDEPTH: boolean;
  47470. SAMPLER3DBGRMAP: boolean;
  47471. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47472. EXPOSURE: boolean;
  47473. MULTIVIEW: boolean;
  47474. USEPHYSICALLIGHTFALLOFF: boolean;
  47475. USEGLTFLIGHTFALLOFF: boolean;
  47476. TWOSIDEDLIGHTING: boolean;
  47477. SHADOWFLOAT: boolean;
  47478. CLIPPLANE: boolean;
  47479. CLIPPLANE2: boolean;
  47480. CLIPPLANE3: boolean;
  47481. CLIPPLANE4: boolean;
  47482. POINTSIZE: boolean;
  47483. FOG: boolean;
  47484. LOGARITHMICDEPTH: boolean;
  47485. FORCENORMALFORWARD: boolean;
  47486. SPECULARAA: boolean;
  47487. CLEARCOAT: boolean;
  47488. CLEARCOAT_DEFAULTIOR: boolean;
  47489. CLEARCOAT_TEXTURE: boolean;
  47490. CLEARCOAT_TEXTUREDIRECTUV: number;
  47491. CLEARCOAT_BUMP: boolean;
  47492. CLEARCOAT_BUMPDIRECTUV: number;
  47493. CLEARCOAT_TINT: boolean;
  47494. CLEARCOAT_TINT_TEXTURE: boolean;
  47495. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47496. ANISOTROPIC: boolean;
  47497. ANISOTROPIC_TEXTURE: boolean;
  47498. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47499. BRDF_V_HEIGHT_CORRELATED: boolean;
  47500. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47501. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47502. SHEEN: boolean;
  47503. SHEEN_TEXTURE: boolean;
  47504. SHEEN_TEXTUREDIRECTUV: number;
  47505. SHEEN_LINKWITHALBEDO: boolean;
  47506. SUBSURFACE: boolean;
  47507. SS_REFRACTION: boolean;
  47508. SS_TRANSLUCENCY: boolean;
  47509. SS_SCATERRING: boolean;
  47510. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47511. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47512. SS_REFRACTIONMAP_3D: boolean;
  47513. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47514. SS_LODINREFRACTIONALPHA: boolean;
  47515. SS_GAMMAREFRACTION: boolean;
  47516. SS_RGBDREFRACTION: boolean;
  47517. SS_LINEARSPECULARREFRACTION: boolean;
  47518. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47519. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47520. UNLIT: boolean;
  47521. DEBUGMODE: number;
  47522. /**
  47523. * Initializes the PBR Material defines.
  47524. */
  47525. constructor();
  47526. /**
  47527. * Resets the PBR Material defines.
  47528. */
  47529. reset(): void;
  47530. }
  47531. /**
  47532. * The Physically based material base class of BJS.
  47533. *
  47534. * This offers the main features of a standard PBR material.
  47535. * For more information, please refer to the documentation :
  47536. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47537. */
  47538. export abstract class PBRBaseMaterial extends PushMaterial {
  47539. /**
  47540. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47541. */
  47542. static readonly PBRMATERIAL_OPAQUE: number;
  47543. /**
  47544. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47545. */
  47546. static readonly PBRMATERIAL_ALPHATEST: number;
  47547. /**
  47548. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47549. */
  47550. static readonly PBRMATERIAL_ALPHABLEND: number;
  47551. /**
  47552. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47553. * They are also discarded below the alpha cutoff threshold to improve performances.
  47554. */
  47555. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47556. /**
  47557. * Defines the default value of how much AO map is occluding the analytical lights
  47558. * (point spot...).
  47559. */
  47560. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47561. /**
  47562. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47563. */
  47564. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47565. /**
  47566. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47567. * to enhance interoperability with other engines.
  47568. */
  47569. static readonly LIGHTFALLOFF_GLTF: number;
  47570. /**
  47571. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47572. * to enhance interoperability with other materials.
  47573. */
  47574. static readonly LIGHTFALLOFF_STANDARD: number;
  47575. /**
  47576. * Intensity of the direct lights e.g. the four lights available in your scene.
  47577. * This impacts both the direct diffuse and specular highlights.
  47578. */
  47579. protected _directIntensity: number;
  47580. /**
  47581. * Intensity of the emissive part of the material.
  47582. * This helps controlling the emissive effect without modifying the emissive color.
  47583. */
  47584. protected _emissiveIntensity: number;
  47585. /**
  47586. * Intensity of the environment e.g. how much the environment will light the object
  47587. * either through harmonics for rough material or through the refelction for shiny ones.
  47588. */
  47589. protected _environmentIntensity: number;
  47590. /**
  47591. * This is a special control allowing the reduction of the specular highlights coming from the
  47592. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47593. */
  47594. protected _specularIntensity: number;
  47595. /**
  47596. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47597. */
  47598. private _lightingInfos;
  47599. /**
  47600. * Debug Control allowing disabling the bump map on this material.
  47601. */
  47602. protected _disableBumpMap: boolean;
  47603. /**
  47604. * AKA Diffuse Texture in standard nomenclature.
  47605. */
  47606. protected _albedoTexture: Nullable<BaseTexture>;
  47607. /**
  47608. * AKA Occlusion Texture in other nomenclature.
  47609. */
  47610. protected _ambientTexture: Nullable<BaseTexture>;
  47611. /**
  47612. * AKA Occlusion Texture Intensity in other nomenclature.
  47613. */
  47614. protected _ambientTextureStrength: number;
  47615. /**
  47616. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47617. * 1 means it completely occludes it
  47618. * 0 mean it has no impact
  47619. */
  47620. protected _ambientTextureImpactOnAnalyticalLights: number;
  47621. /**
  47622. * Stores the alpha values in a texture.
  47623. */
  47624. protected _opacityTexture: Nullable<BaseTexture>;
  47625. /**
  47626. * Stores the reflection values in a texture.
  47627. */
  47628. protected _reflectionTexture: Nullable<BaseTexture>;
  47629. /**
  47630. * Stores the emissive values in a texture.
  47631. */
  47632. protected _emissiveTexture: Nullable<BaseTexture>;
  47633. /**
  47634. * AKA Specular texture in other nomenclature.
  47635. */
  47636. protected _reflectivityTexture: Nullable<BaseTexture>;
  47637. /**
  47638. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47639. */
  47640. protected _metallicTexture: Nullable<BaseTexture>;
  47641. /**
  47642. * Specifies the metallic scalar of the metallic/roughness workflow.
  47643. * Can also be used to scale the metalness values of the metallic texture.
  47644. */
  47645. protected _metallic: Nullable<number>;
  47646. /**
  47647. * Specifies the roughness scalar of the metallic/roughness workflow.
  47648. * Can also be used to scale the roughness values of the metallic texture.
  47649. */
  47650. protected _roughness: Nullable<number>;
  47651. /**
  47652. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47653. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47654. */
  47655. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47656. /**
  47657. * Stores surface normal data used to displace a mesh in a texture.
  47658. */
  47659. protected _bumpTexture: Nullable<BaseTexture>;
  47660. /**
  47661. * Stores the pre-calculated light information of a mesh in a texture.
  47662. */
  47663. protected _lightmapTexture: Nullable<BaseTexture>;
  47664. /**
  47665. * The color of a material in ambient lighting.
  47666. */
  47667. protected _ambientColor: Color3;
  47668. /**
  47669. * AKA Diffuse Color in other nomenclature.
  47670. */
  47671. protected _albedoColor: Color3;
  47672. /**
  47673. * AKA Specular Color in other nomenclature.
  47674. */
  47675. protected _reflectivityColor: Color3;
  47676. /**
  47677. * The color applied when light is reflected from a material.
  47678. */
  47679. protected _reflectionColor: Color3;
  47680. /**
  47681. * The color applied when light is emitted from a material.
  47682. */
  47683. protected _emissiveColor: Color3;
  47684. /**
  47685. * AKA Glossiness in other nomenclature.
  47686. */
  47687. protected _microSurface: number;
  47688. /**
  47689. * Specifies that the material will use the light map as a show map.
  47690. */
  47691. protected _useLightmapAsShadowmap: boolean;
  47692. /**
  47693. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47694. * makes the reflect vector face the model (under horizon).
  47695. */
  47696. protected _useHorizonOcclusion: boolean;
  47697. /**
  47698. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47699. * too much the area relying on ambient texture to define their ambient occlusion.
  47700. */
  47701. protected _useRadianceOcclusion: boolean;
  47702. /**
  47703. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47704. */
  47705. protected _useAlphaFromAlbedoTexture: boolean;
  47706. /**
  47707. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47708. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47709. */
  47710. protected _useSpecularOverAlpha: boolean;
  47711. /**
  47712. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47713. */
  47714. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47715. /**
  47716. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47717. */
  47718. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47719. /**
  47720. * Specifies if the metallic texture contains the roughness information in its green channel.
  47721. */
  47722. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47723. /**
  47724. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47725. */
  47726. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47727. /**
  47728. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47729. */
  47730. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47731. /**
  47732. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47733. */
  47734. protected _useAmbientInGrayScale: boolean;
  47735. /**
  47736. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47737. * The material will try to infer what glossiness each pixel should be.
  47738. */
  47739. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47740. /**
  47741. * Defines the falloff type used in this material.
  47742. * It by default is Physical.
  47743. */
  47744. protected _lightFalloff: number;
  47745. /**
  47746. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47747. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47748. */
  47749. protected _useRadianceOverAlpha: boolean;
  47750. /**
  47751. * Allows using an object space normal map (instead of tangent space).
  47752. */
  47753. protected _useObjectSpaceNormalMap: boolean;
  47754. /**
  47755. * Allows using the bump map in parallax mode.
  47756. */
  47757. protected _useParallax: boolean;
  47758. /**
  47759. * Allows using the bump map in parallax occlusion mode.
  47760. */
  47761. protected _useParallaxOcclusion: boolean;
  47762. /**
  47763. * Controls the scale bias of the parallax mode.
  47764. */
  47765. protected _parallaxScaleBias: number;
  47766. /**
  47767. * If sets to true, disables all the lights affecting the material.
  47768. */
  47769. protected _disableLighting: boolean;
  47770. /**
  47771. * Number of Simultaneous lights allowed on the material.
  47772. */
  47773. protected _maxSimultaneousLights: number;
  47774. /**
  47775. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47776. */
  47777. protected _invertNormalMapX: boolean;
  47778. /**
  47779. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47780. */
  47781. protected _invertNormalMapY: boolean;
  47782. /**
  47783. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47784. */
  47785. protected _twoSidedLighting: boolean;
  47786. /**
  47787. * Defines the alpha limits in alpha test mode.
  47788. */
  47789. protected _alphaCutOff: number;
  47790. /**
  47791. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47792. */
  47793. protected _forceAlphaTest: boolean;
  47794. /**
  47795. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47796. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47797. */
  47798. protected _useAlphaFresnel: boolean;
  47799. /**
  47800. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47801. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47802. */
  47803. protected _useLinearAlphaFresnel: boolean;
  47804. /**
  47805. * The transparency mode of the material.
  47806. */
  47807. protected _transparencyMode: Nullable<number>;
  47808. /**
  47809. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47810. * from cos thetav and roughness:
  47811. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47812. */
  47813. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47814. /**
  47815. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47816. */
  47817. protected _forceIrradianceInFragment: boolean;
  47818. /**
  47819. * Force normal to face away from face.
  47820. */
  47821. protected _forceNormalForward: boolean;
  47822. /**
  47823. * Enables specular anti aliasing in the PBR shader.
  47824. * It will both interacts on the Geometry for analytical and IBL lighting.
  47825. * It also prefilter the roughness map based on the bump values.
  47826. */
  47827. protected _enableSpecularAntiAliasing: boolean;
  47828. /**
  47829. * Default configuration related to image processing available in the PBR Material.
  47830. */
  47831. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47832. /**
  47833. * Keep track of the image processing observer to allow dispose and replace.
  47834. */
  47835. private _imageProcessingObserver;
  47836. /**
  47837. * Attaches a new image processing configuration to the PBR Material.
  47838. * @param configuration
  47839. */
  47840. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47841. /**
  47842. * Stores the available render targets.
  47843. */
  47844. private _renderTargets;
  47845. /**
  47846. * Sets the global ambient color for the material used in lighting calculations.
  47847. */
  47848. private _globalAmbientColor;
  47849. /**
  47850. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47851. */
  47852. private _useLogarithmicDepth;
  47853. /**
  47854. * If set to true, no lighting calculations will be applied.
  47855. */
  47856. private _unlit;
  47857. private _debugMode;
  47858. /**
  47859. * @hidden
  47860. * This is reserved for the inspector.
  47861. * Defines the material debug mode.
  47862. * It helps seeing only some components of the material while troubleshooting.
  47863. */
  47864. debugMode: number;
  47865. /**
  47866. * @hidden
  47867. * This is reserved for the inspector.
  47868. * Specify from where on screen the debug mode should start.
  47869. * The value goes from -1 (full screen) to 1 (not visible)
  47870. * It helps with side by side comparison against the final render
  47871. * This defaults to -1
  47872. */
  47873. private debugLimit;
  47874. /**
  47875. * @hidden
  47876. * This is reserved for the inspector.
  47877. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47878. * You can use the factor to better multiply the final value.
  47879. */
  47880. private debugFactor;
  47881. /**
  47882. * Defines the clear coat layer parameters for the material.
  47883. */
  47884. readonly clearCoat: PBRClearCoatConfiguration;
  47885. /**
  47886. * Defines the anisotropic parameters for the material.
  47887. */
  47888. readonly anisotropy: PBRAnisotropicConfiguration;
  47889. /**
  47890. * Defines the BRDF parameters for the material.
  47891. */
  47892. readonly brdf: PBRBRDFConfiguration;
  47893. /**
  47894. * Defines the Sheen parameters for the material.
  47895. */
  47896. readonly sheen: PBRSheenConfiguration;
  47897. /**
  47898. * Defines the SubSurface parameters for the material.
  47899. */
  47900. readonly subSurface: PBRSubSurfaceConfiguration;
  47901. /**
  47902. * Custom callback helping to override the default shader used in the material.
  47903. */
  47904. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47905. protected _rebuildInParallel: boolean;
  47906. /**
  47907. * Instantiates a new PBRMaterial instance.
  47908. *
  47909. * @param name The material name
  47910. * @param scene The scene the material will be use in.
  47911. */
  47912. constructor(name: string, scene: Scene);
  47913. /**
  47914. * Gets a boolean indicating that current material needs to register RTT
  47915. */
  47916. readonly hasRenderTargetTextures: boolean;
  47917. /**
  47918. * Gets the name of the material class.
  47919. */
  47920. getClassName(): string;
  47921. /**
  47922. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47923. */
  47924. /**
  47925. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47926. */
  47927. useLogarithmicDepth: boolean;
  47928. /**
  47929. * Gets the current transparency mode.
  47930. */
  47931. /**
  47932. * Sets the transparency mode of the material.
  47933. *
  47934. * | Value | Type | Description |
  47935. * | ----- | ----------------------------------- | ----------- |
  47936. * | 0 | OPAQUE | |
  47937. * | 1 | ALPHATEST | |
  47938. * | 2 | ALPHABLEND | |
  47939. * | 3 | ALPHATESTANDBLEND | |
  47940. *
  47941. */
  47942. transparencyMode: Nullable<number>;
  47943. /**
  47944. * Returns true if alpha blending should be disabled.
  47945. */
  47946. private readonly _disableAlphaBlending;
  47947. /**
  47948. * Specifies whether or not this material should be rendered in alpha blend mode.
  47949. */
  47950. needAlphaBlending(): boolean;
  47951. /**
  47952. * Specifies if the mesh will require alpha blending.
  47953. * @param mesh - BJS mesh.
  47954. */
  47955. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47956. /**
  47957. * Specifies whether or not this material should be rendered in alpha test mode.
  47958. */
  47959. needAlphaTesting(): boolean;
  47960. /**
  47961. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47962. */
  47963. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47964. /**
  47965. * Gets the texture used for the alpha test.
  47966. */
  47967. getAlphaTestTexture(): Nullable<BaseTexture>;
  47968. /**
  47969. * Specifies that the submesh is ready to be used.
  47970. * @param mesh - BJS mesh.
  47971. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47972. * @param useInstances - Specifies that instances should be used.
  47973. * @returns - boolean indicating that the submesh is ready or not.
  47974. */
  47975. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47976. /**
  47977. * Specifies if the material uses metallic roughness workflow.
  47978. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47979. */
  47980. isMetallicWorkflow(): boolean;
  47981. private _prepareEffect;
  47982. private _prepareDefines;
  47983. /**
  47984. * Force shader compilation
  47985. */
  47986. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47987. clipPlane: boolean;
  47988. }>): void;
  47989. /**
  47990. * Initializes the uniform buffer layout for the shader.
  47991. */
  47992. buildUniformLayout(): void;
  47993. /**
  47994. * Unbinds the material from the mesh
  47995. */
  47996. unbind(): void;
  47997. /**
  47998. * Binds the submesh data.
  47999. * @param world - The world matrix.
  48000. * @param mesh - The BJS mesh.
  48001. * @param subMesh - A submesh of the BJS mesh.
  48002. */
  48003. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48004. /**
  48005. * Returns the animatable textures.
  48006. * @returns - Array of animatable textures.
  48007. */
  48008. getAnimatables(): IAnimatable[];
  48009. /**
  48010. * Returns the texture used for reflections.
  48011. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48012. */
  48013. private _getReflectionTexture;
  48014. /**
  48015. * Returns an array of the actively used textures.
  48016. * @returns - Array of BaseTextures
  48017. */
  48018. getActiveTextures(): BaseTexture[];
  48019. /**
  48020. * Checks to see if a texture is used in the material.
  48021. * @param texture - Base texture to use.
  48022. * @returns - Boolean specifying if a texture is used in the material.
  48023. */
  48024. hasTexture(texture: BaseTexture): boolean;
  48025. /**
  48026. * Disposes the resources of the material.
  48027. * @param forceDisposeEffect - Forces the disposal of effects.
  48028. * @param forceDisposeTextures - Forces the disposal of all textures.
  48029. */
  48030. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48031. }
  48032. }
  48033. declare module BABYLON {
  48034. /**
  48035. * The Physically based material of BJS.
  48036. *
  48037. * This offers the main features of a standard PBR material.
  48038. * For more information, please refer to the documentation :
  48039. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48040. */
  48041. export class PBRMaterial extends PBRBaseMaterial {
  48042. /**
  48043. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48044. */
  48045. static readonly PBRMATERIAL_OPAQUE: number;
  48046. /**
  48047. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48048. */
  48049. static readonly PBRMATERIAL_ALPHATEST: number;
  48050. /**
  48051. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48052. */
  48053. static readonly PBRMATERIAL_ALPHABLEND: number;
  48054. /**
  48055. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48056. * They are also discarded below the alpha cutoff threshold to improve performances.
  48057. */
  48058. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48059. /**
  48060. * Defines the default value of how much AO map is occluding the analytical lights
  48061. * (point spot...).
  48062. */
  48063. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48064. /**
  48065. * Intensity of the direct lights e.g. the four lights available in your scene.
  48066. * This impacts both the direct diffuse and specular highlights.
  48067. */
  48068. directIntensity: number;
  48069. /**
  48070. * Intensity of the emissive part of the material.
  48071. * This helps controlling the emissive effect without modifying the emissive color.
  48072. */
  48073. emissiveIntensity: number;
  48074. /**
  48075. * Intensity of the environment e.g. how much the environment will light the object
  48076. * either through harmonics for rough material or through the refelction for shiny ones.
  48077. */
  48078. environmentIntensity: number;
  48079. /**
  48080. * This is a special control allowing the reduction of the specular highlights coming from the
  48081. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48082. */
  48083. specularIntensity: number;
  48084. /**
  48085. * Debug Control allowing disabling the bump map on this material.
  48086. */
  48087. disableBumpMap: boolean;
  48088. /**
  48089. * AKA Diffuse Texture in standard nomenclature.
  48090. */
  48091. albedoTexture: BaseTexture;
  48092. /**
  48093. * AKA Occlusion Texture in other nomenclature.
  48094. */
  48095. ambientTexture: BaseTexture;
  48096. /**
  48097. * AKA Occlusion Texture Intensity in other nomenclature.
  48098. */
  48099. ambientTextureStrength: number;
  48100. /**
  48101. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48102. * 1 means it completely occludes it
  48103. * 0 mean it has no impact
  48104. */
  48105. ambientTextureImpactOnAnalyticalLights: number;
  48106. /**
  48107. * Stores the alpha values in a texture.
  48108. */
  48109. opacityTexture: BaseTexture;
  48110. /**
  48111. * Stores the reflection values in a texture.
  48112. */
  48113. reflectionTexture: Nullable<BaseTexture>;
  48114. /**
  48115. * Stores the emissive values in a texture.
  48116. */
  48117. emissiveTexture: BaseTexture;
  48118. /**
  48119. * AKA Specular texture in other nomenclature.
  48120. */
  48121. reflectivityTexture: BaseTexture;
  48122. /**
  48123. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48124. */
  48125. metallicTexture: BaseTexture;
  48126. /**
  48127. * Specifies the metallic scalar of the metallic/roughness workflow.
  48128. * Can also be used to scale the metalness values of the metallic texture.
  48129. */
  48130. metallic: Nullable<number>;
  48131. /**
  48132. * Specifies the roughness scalar of the metallic/roughness workflow.
  48133. * Can also be used to scale the roughness values of the metallic texture.
  48134. */
  48135. roughness: Nullable<number>;
  48136. /**
  48137. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48138. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48139. */
  48140. microSurfaceTexture: BaseTexture;
  48141. /**
  48142. * Stores surface normal data used to displace a mesh in a texture.
  48143. */
  48144. bumpTexture: BaseTexture;
  48145. /**
  48146. * Stores the pre-calculated light information of a mesh in a texture.
  48147. */
  48148. lightmapTexture: BaseTexture;
  48149. /**
  48150. * Stores the refracted light information in a texture.
  48151. */
  48152. refractionTexture: Nullable<BaseTexture>;
  48153. /**
  48154. * The color of a material in ambient lighting.
  48155. */
  48156. ambientColor: Color3;
  48157. /**
  48158. * AKA Diffuse Color in other nomenclature.
  48159. */
  48160. albedoColor: Color3;
  48161. /**
  48162. * AKA Specular Color in other nomenclature.
  48163. */
  48164. reflectivityColor: Color3;
  48165. /**
  48166. * The color reflected from the material.
  48167. */
  48168. reflectionColor: Color3;
  48169. /**
  48170. * The color emitted from the material.
  48171. */
  48172. emissiveColor: Color3;
  48173. /**
  48174. * AKA Glossiness in other nomenclature.
  48175. */
  48176. microSurface: number;
  48177. /**
  48178. * source material index of refraction (IOR)' / 'destination material IOR.
  48179. */
  48180. indexOfRefraction: number;
  48181. /**
  48182. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48183. */
  48184. invertRefractionY: boolean;
  48185. /**
  48186. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48187. * Materials half opaque for instance using refraction could benefit from this control.
  48188. */
  48189. linkRefractionWithTransparency: boolean;
  48190. /**
  48191. * If true, the light map contains occlusion information instead of lighting info.
  48192. */
  48193. useLightmapAsShadowmap: boolean;
  48194. /**
  48195. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48196. */
  48197. useAlphaFromAlbedoTexture: boolean;
  48198. /**
  48199. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48200. */
  48201. forceAlphaTest: boolean;
  48202. /**
  48203. * Defines the alpha limits in alpha test mode.
  48204. */
  48205. alphaCutOff: number;
  48206. /**
  48207. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48208. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48209. */
  48210. useSpecularOverAlpha: boolean;
  48211. /**
  48212. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48213. */
  48214. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48215. /**
  48216. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48217. */
  48218. useRoughnessFromMetallicTextureAlpha: boolean;
  48219. /**
  48220. * Specifies if the metallic texture contains the roughness information in its green channel.
  48221. */
  48222. useRoughnessFromMetallicTextureGreen: boolean;
  48223. /**
  48224. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48225. */
  48226. useMetallnessFromMetallicTextureBlue: boolean;
  48227. /**
  48228. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48229. */
  48230. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48231. /**
  48232. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48233. */
  48234. useAmbientInGrayScale: boolean;
  48235. /**
  48236. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48237. * The material will try to infer what glossiness each pixel should be.
  48238. */
  48239. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48240. /**
  48241. * BJS is using an harcoded light falloff based on a manually sets up range.
  48242. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48243. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48244. */
  48245. /**
  48246. * BJS is using an harcoded light falloff based on a manually sets up range.
  48247. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48248. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48249. */
  48250. usePhysicalLightFalloff: boolean;
  48251. /**
  48252. * In order to support the falloff compatibility with gltf, a special mode has been added
  48253. * to reproduce the gltf light falloff.
  48254. */
  48255. /**
  48256. * In order to support the falloff compatibility with gltf, a special mode has been added
  48257. * to reproduce the gltf light falloff.
  48258. */
  48259. useGLTFLightFalloff: boolean;
  48260. /**
  48261. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48262. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48263. */
  48264. useRadianceOverAlpha: boolean;
  48265. /**
  48266. * Allows using an object space normal map (instead of tangent space).
  48267. */
  48268. useObjectSpaceNormalMap: boolean;
  48269. /**
  48270. * Allows using the bump map in parallax mode.
  48271. */
  48272. useParallax: boolean;
  48273. /**
  48274. * Allows using the bump map in parallax occlusion mode.
  48275. */
  48276. useParallaxOcclusion: boolean;
  48277. /**
  48278. * Controls the scale bias of the parallax mode.
  48279. */
  48280. parallaxScaleBias: number;
  48281. /**
  48282. * If sets to true, disables all the lights affecting the material.
  48283. */
  48284. disableLighting: boolean;
  48285. /**
  48286. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48287. */
  48288. forceIrradianceInFragment: boolean;
  48289. /**
  48290. * Number of Simultaneous lights allowed on the material.
  48291. */
  48292. maxSimultaneousLights: number;
  48293. /**
  48294. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48295. */
  48296. invertNormalMapX: boolean;
  48297. /**
  48298. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48299. */
  48300. invertNormalMapY: boolean;
  48301. /**
  48302. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48303. */
  48304. twoSidedLighting: boolean;
  48305. /**
  48306. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48307. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48308. */
  48309. useAlphaFresnel: boolean;
  48310. /**
  48311. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48312. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48313. */
  48314. useLinearAlphaFresnel: boolean;
  48315. /**
  48316. * Let user defines the brdf lookup texture used for IBL.
  48317. * A default 8bit version is embedded but you could point at :
  48318. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48319. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48320. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48321. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48322. */
  48323. environmentBRDFTexture: Nullable<BaseTexture>;
  48324. /**
  48325. * Force normal to face away from face.
  48326. */
  48327. forceNormalForward: boolean;
  48328. /**
  48329. * Enables specular anti aliasing in the PBR shader.
  48330. * It will both interacts on the Geometry for analytical and IBL lighting.
  48331. * It also prefilter the roughness map based on the bump values.
  48332. */
  48333. enableSpecularAntiAliasing: boolean;
  48334. /**
  48335. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48336. * makes the reflect vector face the model (under horizon).
  48337. */
  48338. useHorizonOcclusion: boolean;
  48339. /**
  48340. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48341. * too much the area relying on ambient texture to define their ambient occlusion.
  48342. */
  48343. useRadianceOcclusion: boolean;
  48344. /**
  48345. * If set to true, no lighting calculations will be applied.
  48346. */
  48347. unlit: boolean;
  48348. /**
  48349. * Gets the image processing configuration used either in this material.
  48350. */
  48351. /**
  48352. * Sets the Default image processing configuration used either in the this material.
  48353. *
  48354. * If sets to null, the scene one is in use.
  48355. */
  48356. imageProcessingConfiguration: ImageProcessingConfiguration;
  48357. /**
  48358. * Gets wether the color curves effect is enabled.
  48359. */
  48360. /**
  48361. * Sets wether the color curves effect is enabled.
  48362. */
  48363. cameraColorCurvesEnabled: boolean;
  48364. /**
  48365. * Gets wether the color grading effect is enabled.
  48366. */
  48367. /**
  48368. * Gets wether the color grading effect is enabled.
  48369. */
  48370. cameraColorGradingEnabled: boolean;
  48371. /**
  48372. * Gets wether tonemapping is enabled or not.
  48373. */
  48374. /**
  48375. * Sets wether tonemapping is enabled or not
  48376. */
  48377. cameraToneMappingEnabled: boolean;
  48378. /**
  48379. * The camera exposure used on this material.
  48380. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48381. * This corresponds to a photographic exposure.
  48382. */
  48383. /**
  48384. * The camera exposure used on this material.
  48385. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48386. * This corresponds to a photographic exposure.
  48387. */
  48388. cameraExposure: number;
  48389. /**
  48390. * Gets The camera contrast used on this material.
  48391. */
  48392. /**
  48393. * Sets The camera contrast used on this material.
  48394. */
  48395. cameraContrast: number;
  48396. /**
  48397. * Gets the Color Grading 2D Lookup Texture.
  48398. */
  48399. /**
  48400. * Sets the Color Grading 2D Lookup Texture.
  48401. */
  48402. cameraColorGradingTexture: Nullable<BaseTexture>;
  48403. /**
  48404. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48405. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48406. * 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;
  48407. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48408. */
  48409. /**
  48410. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48411. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48412. * 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;
  48413. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48414. */
  48415. cameraColorCurves: Nullable<ColorCurves>;
  48416. /**
  48417. * Instantiates a new PBRMaterial instance.
  48418. *
  48419. * @param name The material name
  48420. * @param scene The scene the material will be use in.
  48421. */
  48422. constructor(name: string, scene: Scene);
  48423. /**
  48424. * Returns the name of this material class.
  48425. */
  48426. getClassName(): string;
  48427. /**
  48428. * Makes a duplicate of the current material.
  48429. * @param name - name to use for the new material.
  48430. */
  48431. clone(name: string): PBRMaterial;
  48432. /**
  48433. * Serializes this PBR Material.
  48434. * @returns - An object with the serialized material.
  48435. */
  48436. serialize(): any;
  48437. /**
  48438. * Parses a PBR Material from a serialized object.
  48439. * @param source - Serialized object.
  48440. * @param scene - BJS scene instance.
  48441. * @param rootUrl - url for the scene object
  48442. * @returns - PBRMaterial
  48443. */
  48444. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48445. }
  48446. }
  48447. declare module BABYLON {
  48448. /**
  48449. * Direct draw surface info
  48450. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48451. */
  48452. export interface DDSInfo {
  48453. /**
  48454. * Width of the texture
  48455. */
  48456. width: number;
  48457. /**
  48458. * Width of the texture
  48459. */
  48460. height: number;
  48461. /**
  48462. * Number of Mipmaps for the texture
  48463. * @see https://en.wikipedia.org/wiki/Mipmap
  48464. */
  48465. mipmapCount: number;
  48466. /**
  48467. * If the textures format is a known fourCC format
  48468. * @see https://www.fourcc.org/
  48469. */
  48470. isFourCC: boolean;
  48471. /**
  48472. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48473. */
  48474. isRGB: boolean;
  48475. /**
  48476. * If the texture is a lumincance format
  48477. */
  48478. isLuminance: boolean;
  48479. /**
  48480. * If this is a cube texture
  48481. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48482. */
  48483. isCube: boolean;
  48484. /**
  48485. * If the texture is a compressed format eg. FOURCC_DXT1
  48486. */
  48487. isCompressed: boolean;
  48488. /**
  48489. * The dxgiFormat of the texture
  48490. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48491. */
  48492. dxgiFormat: number;
  48493. /**
  48494. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48495. */
  48496. textureType: number;
  48497. /**
  48498. * Sphericle polynomial created for the dds texture
  48499. */
  48500. sphericalPolynomial?: SphericalPolynomial;
  48501. }
  48502. /**
  48503. * Class used to provide DDS decompression tools
  48504. */
  48505. export class DDSTools {
  48506. /**
  48507. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48508. */
  48509. static StoreLODInAlphaChannel: boolean;
  48510. /**
  48511. * Gets DDS information from an array buffer
  48512. * @param arrayBuffer defines the array buffer to read data from
  48513. * @returns the DDS information
  48514. */
  48515. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48516. private static _FloatView;
  48517. private static _Int32View;
  48518. private static _ToHalfFloat;
  48519. private static _FromHalfFloat;
  48520. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48521. private static _GetHalfFloatRGBAArrayBuffer;
  48522. private static _GetFloatRGBAArrayBuffer;
  48523. private static _GetFloatAsUIntRGBAArrayBuffer;
  48524. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48525. private static _GetRGBAArrayBuffer;
  48526. private static _ExtractLongWordOrder;
  48527. private static _GetRGBArrayBuffer;
  48528. private static _GetLuminanceArrayBuffer;
  48529. /**
  48530. * Uploads DDS Levels to a Babylon Texture
  48531. * @hidden
  48532. */
  48533. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48534. }
  48535. interface ThinEngine {
  48536. /**
  48537. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48538. * @param rootUrl defines the url where the file to load is located
  48539. * @param scene defines the current scene
  48540. * @param lodScale defines scale to apply to the mip map selection
  48541. * @param lodOffset defines offset to apply to the mip map selection
  48542. * @param onLoad defines an optional callback raised when the texture is loaded
  48543. * @param onError defines an optional callback raised if there is an issue to load the texture
  48544. * @param format defines the format of the data
  48545. * @param forcedExtension defines the extension to use to pick the right loader
  48546. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48547. * @returns the cube texture as an InternalTexture
  48548. */
  48549. 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;
  48550. }
  48551. }
  48552. declare module BABYLON {
  48553. /**
  48554. * Implementation of the DDS Texture Loader.
  48555. * @hidden
  48556. */
  48557. export class _DDSTextureLoader implements IInternalTextureLoader {
  48558. /**
  48559. * Defines wether the loader supports cascade loading the different faces.
  48560. */
  48561. readonly supportCascades: boolean;
  48562. /**
  48563. * This returns if the loader support the current file information.
  48564. * @param extension defines the file extension of the file being loaded
  48565. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48566. * @param fallback defines the fallback internal texture if any
  48567. * @param isBase64 defines whether the texture is encoded as a base64
  48568. * @param isBuffer defines whether the texture data are stored as a buffer
  48569. * @returns true if the loader can load the specified file
  48570. */
  48571. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48572. /**
  48573. * Transform the url before loading if required.
  48574. * @param rootUrl the url of the texture
  48575. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48576. * @returns the transformed texture
  48577. */
  48578. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48579. /**
  48580. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48581. * @param rootUrl the url of the texture
  48582. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48583. * @returns the fallback texture
  48584. */
  48585. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48586. /**
  48587. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48588. * @param data contains the texture data
  48589. * @param texture defines the BabylonJS internal texture
  48590. * @param createPolynomials will be true if polynomials have been requested
  48591. * @param onLoad defines the callback to trigger once the texture is ready
  48592. * @param onError defines the callback to trigger in case of error
  48593. */
  48594. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48595. /**
  48596. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48597. * @param data contains the texture data
  48598. * @param texture defines the BabylonJS internal texture
  48599. * @param callback defines the method to call once ready to upload
  48600. */
  48601. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48602. }
  48603. }
  48604. declare module BABYLON {
  48605. /**
  48606. * Implementation of the ENV Texture Loader.
  48607. * @hidden
  48608. */
  48609. export class _ENVTextureLoader implements IInternalTextureLoader {
  48610. /**
  48611. * Defines wether the loader supports cascade loading the different faces.
  48612. */
  48613. readonly supportCascades: boolean;
  48614. /**
  48615. * This returns if the loader support the current file information.
  48616. * @param extension defines the file extension of the file being loaded
  48617. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48618. * @param fallback defines the fallback internal texture if any
  48619. * @param isBase64 defines whether the texture is encoded as a base64
  48620. * @param isBuffer defines whether the texture data are stored as a buffer
  48621. * @returns true if the loader can load the specified file
  48622. */
  48623. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48624. /**
  48625. * Transform the url before loading if required.
  48626. * @param rootUrl the url of the texture
  48627. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48628. * @returns the transformed texture
  48629. */
  48630. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48631. /**
  48632. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48633. * @param rootUrl the url of the texture
  48634. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48635. * @returns the fallback texture
  48636. */
  48637. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48638. /**
  48639. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48640. * @param data contains the texture data
  48641. * @param texture defines the BabylonJS internal texture
  48642. * @param createPolynomials will be true if polynomials have been requested
  48643. * @param onLoad defines the callback to trigger once the texture is ready
  48644. * @param onError defines the callback to trigger in case of error
  48645. */
  48646. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48647. /**
  48648. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48649. * @param data contains the texture data
  48650. * @param texture defines the BabylonJS internal texture
  48651. * @param callback defines the method to call once ready to upload
  48652. */
  48653. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48654. }
  48655. }
  48656. declare module BABYLON {
  48657. /**
  48658. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48659. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48660. */
  48661. export class KhronosTextureContainer {
  48662. /** contents of the KTX container file */
  48663. arrayBuffer: any;
  48664. private static HEADER_LEN;
  48665. private static COMPRESSED_2D;
  48666. private static COMPRESSED_3D;
  48667. private static TEX_2D;
  48668. private static TEX_3D;
  48669. /**
  48670. * Gets the openGL type
  48671. */
  48672. glType: number;
  48673. /**
  48674. * Gets the openGL type size
  48675. */
  48676. glTypeSize: number;
  48677. /**
  48678. * Gets the openGL format
  48679. */
  48680. glFormat: number;
  48681. /**
  48682. * Gets the openGL internal format
  48683. */
  48684. glInternalFormat: number;
  48685. /**
  48686. * Gets the base internal format
  48687. */
  48688. glBaseInternalFormat: number;
  48689. /**
  48690. * Gets image width in pixel
  48691. */
  48692. pixelWidth: number;
  48693. /**
  48694. * Gets image height in pixel
  48695. */
  48696. pixelHeight: number;
  48697. /**
  48698. * Gets image depth in pixels
  48699. */
  48700. pixelDepth: number;
  48701. /**
  48702. * Gets the number of array elements
  48703. */
  48704. numberOfArrayElements: number;
  48705. /**
  48706. * Gets the number of faces
  48707. */
  48708. numberOfFaces: number;
  48709. /**
  48710. * Gets the number of mipmap levels
  48711. */
  48712. numberOfMipmapLevels: number;
  48713. /**
  48714. * Gets the bytes of key value data
  48715. */
  48716. bytesOfKeyValueData: number;
  48717. /**
  48718. * Gets the load type
  48719. */
  48720. loadType: number;
  48721. /**
  48722. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48723. */
  48724. isInvalid: boolean;
  48725. /**
  48726. * Creates a new KhronosTextureContainer
  48727. * @param arrayBuffer contents of the KTX container file
  48728. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48729. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48730. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48731. */
  48732. constructor(
  48733. /** contents of the KTX container file */
  48734. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48735. /**
  48736. * Uploads KTX content to a Babylon Texture.
  48737. * It is assumed that the texture has already been created & is currently bound
  48738. * @hidden
  48739. */
  48740. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48741. private _upload2DCompressedLevels;
  48742. }
  48743. }
  48744. declare module BABYLON {
  48745. /**
  48746. * Implementation of the KTX Texture Loader.
  48747. * @hidden
  48748. */
  48749. export class _KTXTextureLoader implements IInternalTextureLoader {
  48750. /**
  48751. * Defines wether the loader supports cascade loading the different faces.
  48752. */
  48753. readonly supportCascades: boolean;
  48754. /**
  48755. * This returns if the loader support the current file information.
  48756. * @param extension defines the file extension of the file being loaded
  48757. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48758. * @param fallback defines the fallback internal texture if any
  48759. * @param isBase64 defines whether the texture is encoded as a base64
  48760. * @param isBuffer defines whether the texture data are stored as a buffer
  48761. * @returns true if the loader can load the specified file
  48762. */
  48763. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48764. /**
  48765. * Transform the url before loading if required.
  48766. * @param rootUrl the url of the texture
  48767. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48768. * @returns the transformed texture
  48769. */
  48770. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48771. /**
  48772. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48773. * @param rootUrl the url of the texture
  48774. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48775. * @returns the fallback texture
  48776. */
  48777. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48778. /**
  48779. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48780. * @param data contains the texture data
  48781. * @param texture defines the BabylonJS internal texture
  48782. * @param createPolynomials will be true if polynomials have been requested
  48783. * @param onLoad defines the callback to trigger once the texture is ready
  48784. * @param onError defines the callback to trigger in case of error
  48785. */
  48786. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48787. /**
  48788. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48789. * @param data contains the texture data
  48790. * @param texture defines the BabylonJS internal texture
  48791. * @param callback defines the method to call once ready to upload
  48792. */
  48793. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48794. }
  48795. }
  48796. declare module BABYLON {
  48797. /**
  48798. * Options for the default xr helper
  48799. */
  48800. export class WebXRDefaultExperienceOptions {
  48801. /**
  48802. * Floor meshes that should be used for teleporting
  48803. */
  48804. floorMeshes: Array<AbstractMesh>;
  48805. }
  48806. /**
  48807. * Default experience which provides a similar setup to the previous webVRExperience
  48808. */
  48809. export class WebXRDefaultExperience {
  48810. /**
  48811. * Base experience
  48812. */
  48813. baseExperience: WebXRExperienceHelper;
  48814. /**
  48815. * Input experience extension
  48816. */
  48817. input: WebXRInput;
  48818. /**
  48819. * Loads the controller models
  48820. */
  48821. controllerModelLoader: WebXRControllerModelLoader;
  48822. /**
  48823. * Enables laser pointer and selection
  48824. */
  48825. pointerSelection: WebXRControllerPointerSelection;
  48826. /**
  48827. * Enables teleportation
  48828. */
  48829. teleportation: WebXRControllerTeleportation;
  48830. /**
  48831. * Enables ui for enetering/exiting xr
  48832. */
  48833. enterExitUI: WebXREnterExitUI;
  48834. /**
  48835. * Default output canvas xr should render to
  48836. */
  48837. outputCanvas: WebXRManagedOutputCanvas;
  48838. /**
  48839. * Creates the default xr experience
  48840. * @param scene scene
  48841. * @param options options for basic configuration
  48842. * @returns resulting WebXRDefaultExperience
  48843. */
  48844. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48845. private constructor();
  48846. /**
  48847. * DIsposes of the experience helper
  48848. */
  48849. dispose(): void;
  48850. }
  48851. }
  48852. declare module BABYLON {
  48853. /** @hidden */
  48854. export var _forceSceneHelpersToBundle: boolean;
  48855. interface Scene {
  48856. /**
  48857. * Creates a default light for the scene.
  48858. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48859. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48860. */
  48861. createDefaultLight(replace?: boolean): void;
  48862. /**
  48863. * Creates a default camera for the scene.
  48864. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48865. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48866. * @param replace has default false, when true replaces the active camera in the scene
  48867. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48868. */
  48869. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48870. /**
  48871. * Creates a default camera and a default light.
  48872. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48873. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48874. * @param replace has the default false, when true replaces the active camera/light in the scene
  48875. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48876. */
  48877. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48878. /**
  48879. * Creates a new sky box
  48880. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48881. * @param environmentTexture defines the texture to use as environment texture
  48882. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48883. * @param scale defines the overall scale of the skybox
  48884. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48885. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48886. * @returns a new mesh holding the sky box
  48887. */
  48888. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48889. /**
  48890. * Creates a new environment
  48891. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48892. * @param options defines the options you can use to configure the environment
  48893. * @returns the new EnvironmentHelper
  48894. */
  48895. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48896. /**
  48897. * Creates a new VREXperienceHelper
  48898. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48899. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48900. * @returns a new VREXperienceHelper
  48901. */
  48902. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48903. /**
  48904. * Creates a new WebXRDefaultExperience
  48905. * @see http://doc.babylonjs.com/how_to/webxr
  48906. * @param options experience options
  48907. * @returns a promise for a new WebXRDefaultExperience
  48908. */
  48909. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48910. }
  48911. }
  48912. declare module BABYLON {
  48913. /**
  48914. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48915. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48916. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48917. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48918. */
  48919. export class VideoDome extends TransformNode {
  48920. /**
  48921. * Define the video source as a Monoscopic panoramic 360 video.
  48922. */
  48923. static readonly MODE_MONOSCOPIC: number;
  48924. /**
  48925. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48926. */
  48927. static readonly MODE_TOPBOTTOM: number;
  48928. /**
  48929. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48930. */
  48931. static readonly MODE_SIDEBYSIDE: number;
  48932. private _halfDome;
  48933. private _useDirectMapping;
  48934. /**
  48935. * The video texture being displayed on the sphere
  48936. */
  48937. protected _videoTexture: VideoTexture;
  48938. /**
  48939. * Gets the video texture being displayed on the sphere
  48940. */
  48941. readonly videoTexture: VideoTexture;
  48942. /**
  48943. * The skybox material
  48944. */
  48945. protected _material: BackgroundMaterial;
  48946. /**
  48947. * The surface used for the skybox
  48948. */
  48949. protected _mesh: Mesh;
  48950. /**
  48951. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48952. */
  48953. private _halfDomeMask;
  48954. /**
  48955. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48956. * Also see the options.resolution property.
  48957. */
  48958. fovMultiplier: number;
  48959. private _videoMode;
  48960. /**
  48961. * Gets or set the current video mode for the video. It can be:
  48962. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48963. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48964. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48965. */
  48966. videoMode: number;
  48967. /**
  48968. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48969. *
  48970. */
  48971. /**
  48972. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48973. */
  48974. halfDome: boolean;
  48975. /**
  48976. * Oberserver used in Stereoscopic VR Mode.
  48977. */
  48978. private _onBeforeCameraRenderObserver;
  48979. /**
  48980. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48981. * @param name Element's name, child elements will append suffixes for their own names.
  48982. * @param urlsOrVideo defines the url(s) or the video element to use
  48983. * @param options An object containing optional or exposed sub element properties
  48984. */
  48985. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48986. resolution?: number;
  48987. clickToPlay?: boolean;
  48988. autoPlay?: boolean;
  48989. loop?: boolean;
  48990. size?: number;
  48991. poster?: string;
  48992. faceForward?: boolean;
  48993. useDirectMapping?: boolean;
  48994. halfDomeMode?: boolean;
  48995. }, scene: Scene);
  48996. private _changeVideoMode;
  48997. /**
  48998. * Releases resources associated with this node.
  48999. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49000. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49001. */
  49002. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49003. }
  49004. }
  49005. declare module BABYLON {
  49006. /**
  49007. * This class can be used to get instrumentation data from a Babylon engine
  49008. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49009. */
  49010. export class EngineInstrumentation implements IDisposable {
  49011. /**
  49012. * Define the instrumented engine.
  49013. */
  49014. engine: Engine;
  49015. private _captureGPUFrameTime;
  49016. private _gpuFrameTimeToken;
  49017. private _gpuFrameTime;
  49018. private _captureShaderCompilationTime;
  49019. private _shaderCompilationTime;
  49020. private _onBeginFrameObserver;
  49021. private _onEndFrameObserver;
  49022. private _onBeforeShaderCompilationObserver;
  49023. private _onAfterShaderCompilationObserver;
  49024. /**
  49025. * Gets the perf counter used for GPU frame time
  49026. */
  49027. readonly gpuFrameTimeCounter: PerfCounter;
  49028. /**
  49029. * Gets the GPU frame time capture status
  49030. */
  49031. /**
  49032. * Enable or disable the GPU frame time capture
  49033. */
  49034. captureGPUFrameTime: boolean;
  49035. /**
  49036. * Gets the perf counter used for shader compilation time
  49037. */
  49038. readonly shaderCompilationTimeCounter: PerfCounter;
  49039. /**
  49040. * Gets the shader compilation time capture status
  49041. */
  49042. /**
  49043. * Enable or disable the shader compilation time capture
  49044. */
  49045. captureShaderCompilationTime: boolean;
  49046. /**
  49047. * Instantiates a new engine instrumentation.
  49048. * This class can be used to get instrumentation data from a Babylon engine
  49049. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49050. * @param engine Defines the engine to instrument
  49051. */
  49052. constructor(
  49053. /**
  49054. * Define the instrumented engine.
  49055. */
  49056. engine: Engine);
  49057. /**
  49058. * Dispose and release associated resources.
  49059. */
  49060. dispose(): void;
  49061. }
  49062. }
  49063. declare module BABYLON {
  49064. /**
  49065. * This class can be used to get instrumentation data from a Babylon engine
  49066. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49067. */
  49068. export class SceneInstrumentation implements IDisposable {
  49069. /**
  49070. * Defines the scene to instrument
  49071. */
  49072. scene: Scene;
  49073. private _captureActiveMeshesEvaluationTime;
  49074. private _activeMeshesEvaluationTime;
  49075. private _captureRenderTargetsRenderTime;
  49076. private _renderTargetsRenderTime;
  49077. private _captureFrameTime;
  49078. private _frameTime;
  49079. private _captureRenderTime;
  49080. private _renderTime;
  49081. private _captureInterFrameTime;
  49082. private _interFrameTime;
  49083. private _captureParticlesRenderTime;
  49084. private _particlesRenderTime;
  49085. private _captureSpritesRenderTime;
  49086. private _spritesRenderTime;
  49087. private _capturePhysicsTime;
  49088. private _physicsTime;
  49089. private _captureAnimationsTime;
  49090. private _animationsTime;
  49091. private _captureCameraRenderTime;
  49092. private _cameraRenderTime;
  49093. private _onBeforeActiveMeshesEvaluationObserver;
  49094. private _onAfterActiveMeshesEvaluationObserver;
  49095. private _onBeforeRenderTargetsRenderObserver;
  49096. private _onAfterRenderTargetsRenderObserver;
  49097. private _onAfterRenderObserver;
  49098. private _onBeforeDrawPhaseObserver;
  49099. private _onAfterDrawPhaseObserver;
  49100. private _onBeforeAnimationsObserver;
  49101. private _onBeforeParticlesRenderingObserver;
  49102. private _onAfterParticlesRenderingObserver;
  49103. private _onBeforeSpritesRenderingObserver;
  49104. private _onAfterSpritesRenderingObserver;
  49105. private _onBeforePhysicsObserver;
  49106. private _onAfterPhysicsObserver;
  49107. private _onAfterAnimationsObserver;
  49108. private _onBeforeCameraRenderObserver;
  49109. private _onAfterCameraRenderObserver;
  49110. /**
  49111. * Gets the perf counter used for active meshes evaluation time
  49112. */
  49113. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49114. /**
  49115. * Gets the active meshes evaluation time capture status
  49116. */
  49117. /**
  49118. * Enable or disable the active meshes evaluation time capture
  49119. */
  49120. captureActiveMeshesEvaluationTime: boolean;
  49121. /**
  49122. * Gets the perf counter used for render targets render time
  49123. */
  49124. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49125. /**
  49126. * Gets the render targets render time capture status
  49127. */
  49128. /**
  49129. * Enable or disable the render targets render time capture
  49130. */
  49131. captureRenderTargetsRenderTime: boolean;
  49132. /**
  49133. * Gets the perf counter used for particles render time
  49134. */
  49135. readonly particlesRenderTimeCounter: PerfCounter;
  49136. /**
  49137. * Gets the particles render time capture status
  49138. */
  49139. /**
  49140. * Enable or disable the particles render time capture
  49141. */
  49142. captureParticlesRenderTime: boolean;
  49143. /**
  49144. * Gets the perf counter used for sprites render time
  49145. */
  49146. readonly spritesRenderTimeCounter: PerfCounter;
  49147. /**
  49148. * Gets the sprites render time capture status
  49149. */
  49150. /**
  49151. * Enable or disable the sprites render time capture
  49152. */
  49153. captureSpritesRenderTime: boolean;
  49154. /**
  49155. * Gets the perf counter used for physics time
  49156. */
  49157. readonly physicsTimeCounter: PerfCounter;
  49158. /**
  49159. * Gets the physics time capture status
  49160. */
  49161. /**
  49162. * Enable or disable the physics time capture
  49163. */
  49164. capturePhysicsTime: boolean;
  49165. /**
  49166. * Gets the perf counter used for animations time
  49167. */
  49168. readonly animationsTimeCounter: PerfCounter;
  49169. /**
  49170. * Gets the animations time capture status
  49171. */
  49172. /**
  49173. * Enable or disable the animations time capture
  49174. */
  49175. captureAnimationsTime: boolean;
  49176. /**
  49177. * Gets the perf counter used for frame time capture
  49178. */
  49179. readonly frameTimeCounter: PerfCounter;
  49180. /**
  49181. * Gets the frame time capture status
  49182. */
  49183. /**
  49184. * Enable or disable the frame time capture
  49185. */
  49186. captureFrameTime: boolean;
  49187. /**
  49188. * Gets the perf counter used for inter-frames time capture
  49189. */
  49190. readonly interFrameTimeCounter: PerfCounter;
  49191. /**
  49192. * Gets the inter-frames time capture status
  49193. */
  49194. /**
  49195. * Enable or disable the inter-frames time capture
  49196. */
  49197. captureInterFrameTime: boolean;
  49198. /**
  49199. * Gets the perf counter used for render time capture
  49200. */
  49201. readonly renderTimeCounter: PerfCounter;
  49202. /**
  49203. * Gets the render time capture status
  49204. */
  49205. /**
  49206. * Enable or disable the render time capture
  49207. */
  49208. captureRenderTime: boolean;
  49209. /**
  49210. * Gets the perf counter used for camera render time capture
  49211. */
  49212. readonly cameraRenderTimeCounter: PerfCounter;
  49213. /**
  49214. * Gets the camera render time capture status
  49215. */
  49216. /**
  49217. * Enable or disable the camera render time capture
  49218. */
  49219. captureCameraRenderTime: boolean;
  49220. /**
  49221. * Gets the perf counter used for draw calls
  49222. */
  49223. readonly drawCallsCounter: PerfCounter;
  49224. /**
  49225. * Instantiates a new scene instrumentation.
  49226. * This class can be used to get instrumentation data from a Babylon engine
  49227. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49228. * @param scene Defines the scene to instrument
  49229. */
  49230. constructor(
  49231. /**
  49232. * Defines the scene to instrument
  49233. */
  49234. scene: Scene);
  49235. /**
  49236. * Dispose and release associated resources.
  49237. */
  49238. dispose(): void;
  49239. }
  49240. }
  49241. declare module BABYLON {
  49242. /** @hidden */
  49243. export var glowMapGenerationPixelShader: {
  49244. name: string;
  49245. shader: string;
  49246. };
  49247. }
  49248. declare module BABYLON {
  49249. /** @hidden */
  49250. export var glowMapGenerationVertexShader: {
  49251. name: string;
  49252. shader: string;
  49253. };
  49254. }
  49255. declare module BABYLON {
  49256. /**
  49257. * Effect layer options. This helps customizing the behaviour
  49258. * of the effect layer.
  49259. */
  49260. export interface IEffectLayerOptions {
  49261. /**
  49262. * Multiplication factor apply to the canvas size to compute the render target size
  49263. * used to generated the objects (the smaller the faster).
  49264. */
  49265. mainTextureRatio: number;
  49266. /**
  49267. * Enforces a fixed size texture to ensure effect stability across devices.
  49268. */
  49269. mainTextureFixedSize?: number;
  49270. /**
  49271. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49272. */
  49273. alphaBlendingMode: number;
  49274. /**
  49275. * The camera attached to the layer.
  49276. */
  49277. camera: Nullable<Camera>;
  49278. /**
  49279. * The rendering group to draw the layer in.
  49280. */
  49281. renderingGroupId: number;
  49282. }
  49283. /**
  49284. * The effect layer Helps adding post process effect blended with the main pass.
  49285. *
  49286. * This can be for instance use to generate glow or higlight effects on the scene.
  49287. *
  49288. * The effect layer class can not be used directly and is intented to inherited from to be
  49289. * customized per effects.
  49290. */
  49291. export abstract class EffectLayer {
  49292. private _vertexBuffers;
  49293. private _indexBuffer;
  49294. private _cachedDefines;
  49295. private _effectLayerMapGenerationEffect;
  49296. private _effectLayerOptions;
  49297. private _mergeEffect;
  49298. protected _scene: Scene;
  49299. protected _engine: Engine;
  49300. protected _maxSize: number;
  49301. protected _mainTextureDesiredSize: ISize;
  49302. protected _mainTexture: RenderTargetTexture;
  49303. protected _shouldRender: boolean;
  49304. protected _postProcesses: PostProcess[];
  49305. protected _textures: BaseTexture[];
  49306. protected _emissiveTextureAndColor: {
  49307. texture: Nullable<BaseTexture>;
  49308. color: Color4;
  49309. };
  49310. /**
  49311. * The name of the layer
  49312. */
  49313. name: string;
  49314. /**
  49315. * The clear color of the texture used to generate the glow map.
  49316. */
  49317. neutralColor: Color4;
  49318. /**
  49319. * Specifies wether the highlight layer is enabled or not.
  49320. */
  49321. isEnabled: boolean;
  49322. /**
  49323. * Gets the camera attached to the layer.
  49324. */
  49325. readonly camera: Nullable<Camera>;
  49326. /**
  49327. * Gets the rendering group id the layer should render in.
  49328. */
  49329. renderingGroupId: number;
  49330. /**
  49331. * An event triggered when the effect layer has been disposed.
  49332. */
  49333. onDisposeObservable: Observable<EffectLayer>;
  49334. /**
  49335. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49336. */
  49337. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49338. /**
  49339. * An event triggered when the generated texture is being merged in the scene.
  49340. */
  49341. onBeforeComposeObservable: Observable<EffectLayer>;
  49342. /**
  49343. * An event triggered when the generated texture has been merged in the scene.
  49344. */
  49345. onAfterComposeObservable: Observable<EffectLayer>;
  49346. /**
  49347. * An event triggered when the efffect layer changes its size.
  49348. */
  49349. onSizeChangedObservable: Observable<EffectLayer>;
  49350. /** @hidden */
  49351. static _SceneComponentInitialization: (scene: Scene) => void;
  49352. /**
  49353. * Instantiates a new effect Layer and references it in the scene.
  49354. * @param name The name of the layer
  49355. * @param scene The scene to use the layer in
  49356. */
  49357. constructor(
  49358. /** The Friendly of the effect in the scene */
  49359. name: string, scene: Scene);
  49360. /**
  49361. * Get the effect name of the layer.
  49362. * @return The effect name
  49363. */
  49364. abstract getEffectName(): string;
  49365. /**
  49366. * Checks for the readiness of the element composing the layer.
  49367. * @param subMesh the mesh to check for
  49368. * @param useInstances specify wether or not to use instances to render the mesh
  49369. * @return true if ready otherwise, false
  49370. */
  49371. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49372. /**
  49373. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49374. * @returns true if the effect requires stencil during the main canvas render pass.
  49375. */
  49376. abstract needStencil(): boolean;
  49377. /**
  49378. * Create the merge effect. This is the shader use to blit the information back
  49379. * to the main canvas at the end of the scene rendering.
  49380. * @returns The effect containing the shader used to merge the effect on the main canvas
  49381. */
  49382. protected abstract _createMergeEffect(): Effect;
  49383. /**
  49384. * Creates the render target textures and post processes used in the effect layer.
  49385. */
  49386. protected abstract _createTextureAndPostProcesses(): void;
  49387. /**
  49388. * Implementation specific of rendering the generating effect on the main canvas.
  49389. * @param effect The effect used to render through
  49390. */
  49391. protected abstract _internalRender(effect: Effect): void;
  49392. /**
  49393. * Sets the required values for both the emissive texture and and the main color.
  49394. */
  49395. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49396. /**
  49397. * Free any resources and references associated to a mesh.
  49398. * Internal use
  49399. * @param mesh The mesh to free.
  49400. */
  49401. abstract _disposeMesh(mesh: Mesh): void;
  49402. /**
  49403. * Serializes this layer (Glow or Highlight for example)
  49404. * @returns a serialized layer object
  49405. */
  49406. abstract serialize?(): any;
  49407. /**
  49408. * Initializes the effect layer with the required options.
  49409. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49410. */
  49411. protected _init(options: Partial<IEffectLayerOptions>): void;
  49412. /**
  49413. * Generates the index buffer of the full screen quad blending to the main canvas.
  49414. */
  49415. private _generateIndexBuffer;
  49416. /**
  49417. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49418. */
  49419. private _generateVertexBuffer;
  49420. /**
  49421. * Sets the main texture desired size which is the closest power of two
  49422. * of the engine canvas size.
  49423. */
  49424. private _setMainTextureSize;
  49425. /**
  49426. * Creates the main texture for the effect layer.
  49427. */
  49428. protected _createMainTexture(): void;
  49429. /**
  49430. * Adds specific effects defines.
  49431. * @param defines The defines to add specifics to.
  49432. */
  49433. protected _addCustomEffectDefines(defines: string[]): void;
  49434. /**
  49435. * Checks for the readiness of the element composing the layer.
  49436. * @param subMesh the mesh to check for
  49437. * @param useInstances specify wether or not to use instances to render the mesh
  49438. * @param emissiveTexture the associated emissive texture used to generate the glow
  49439. * @return true if ready otherwise, false
  49440. */
  49441. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49442. /**
  49443. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49444. */
  49445. render(): void;
  49446. /**
  49447. * Determine if a given mesh will be used in the current effect.
  49448. * @param mesh mesh to test
  49449. * @returns true if the mesh will be used
  49450. */
  49451. hasMesh(mesh: AbstractMesh): boolean;
  49452. /**
  49453. * Returns true if the layer contains information to display, otherwise false.
  49454. * @returns true if the glow layer should be rendered
  49455. */
  49456. shouldRender(): boolean;
  49457. /**
  49458. * Returns true if the mesh should render, otherwise false.
  49459. * @param mesh The mesh to render
  49460. * @returns true if it should render otherwise false
  49461. */
  49462. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49463. /**
  49464. * Returns true if the mesh can be rendered, otherwise false.
  49465. * @param mesh The mesh to render
  49466. * @param material The material used on the mesh
  49467. * @returns true if it can be rendered otherwise false
  49468. */
  49469. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49470. /**
  49471. * Returns true if the mesh should render, otherwise false.
  49472. * @param mesh The mesh to render
  49473. * @returns true if it should render otherwise false
  49474. */
  49475. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49476. /**
  49477. * Renders the submesh passed in parameter to the generation map.
  49478. */
  49479. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49480. /**
  49481. * Rebuild the required buffers.
  49482. * @hidden Internal use only.
  49483. */
  49484. _rebuild(): void;
  49485. /**
  49486. * Dispose only the render target textures and post process.
  49487. */
  49488. private _disposeTextureAndPostProcesses;
  49489. /**
  49490. * Dispose the highlight layer and free resources.
  49491. */
  49492. dispose(): void;
  49493. /**
  49494. * Gets the class name of the effect layer
  49495. * @returns the string with the class name of the effect layer
  49496. */
  49497. getClassName(): string;
  49498. /**
  49499. * Creates an effect layer from parsed effect layer data
  49500. * @param parsedEffectLayer defines effect layer data
  49501. * @param scene defines the current scene
  49502. * @param rootUrl defines the root URL containing the effect layer information
  49503. * @returns a parsed effect Layer
  49504. */
  49505. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49506. }
  49507. }
  49508. declare module BABYLON {
  49509. interface AbstractScene {
  49510. /**
  49511. * The list of effect layers (highlights/glow) added to the scene
  49512. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49513. * @see http://doc.babylonjs.com/how_to/glow_layer
  49514. */
  49515. effectLayers: Array<EffectLayer>;
  49516. /**
  49517. * Removes the given effect layer from this scene.
  49518. * @param toRemove defines the effect layer to remove
  49519. * @returns the index of the removed effect layer
  49520. */
  49521. removeEffectLayer(toRemove: EffectLayer): number;
  49522. /**
  49523. * Adds the given effect layer to this scene
  49524. * @param newEffectLayer defines the effect layer to add
  49525. */
  49526. addEffectLayer(newEffectLayer: EffectLayer): void;
  49527. }
  49528. /**
  49529. * Defines the layer scene component responsible to manage any effect layers
  49530. * in a given scene.
  49531. */
  49532. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49533. /**
  49534. * The component name helpfull to identify the component in the list of scene components.
  49535. */
  49536. readonly name: string;
  49537. /**
  49538. * The scene the component belongs to.
  49539. */
  49540. scene: Scene;
  49541. private _engine;
  49542. private _renderEffects;
  49543. private _needStencil;
  49544. private _previousStencilState;
  49545. /**
  49546. * Creates a new instance of the component for the given scene
  49547. * @param scene Defines the scene to register the component in
  49548. */
  49549. constructor(scene: Scene);
  49550. /**
  49551. * Registers the component in a given scene
  49552. */
  49553. register(): void;
  49554. /**
  49555. * Rebuilds the elements related to this component in case of
  49556. * context lost for instance.
  49557. */
  49558. rebuild(): void;
  49559. /**
  49560. * Serializes the component data to the specified json object
  49561. * @param serializationObject The object to serialize to
  49562. */
  49563. serialize(serializationObject: any): void;
  49564. /**
  49565. * Adds all the elements from the container to the scene
  49566. * @param container the container holding the elements
  49567. */
  49568. addFromContainer(container: AbstractScene): void;
  49569. /**
  49570. * Removes all the elements in the container from the scene
  49571. * @param container contains the elements to remove
  49572. * @param dispose if the removed element should be disposed (default: false)
  49573. */
  49574. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49575. /**
  49576. * Disposes the component and the associated ressources.
  49577. */
  49578. dispose(): void;
  49579. private _isReadyForMesh;
  49580. private _renderMainTexture;
  49581. private _setStencil;
  49582. private _setStencilBack;
  49583. private _draw;
  49584. private _drawCamera;
  49585. private _drawRenderingGroup;
  49586. }
  49587. }
  49588. declare module BABYLON {
  49589. /** @hidden */
  49590. export var glowMapMergePixelShader: {
  49591. name: string;
  49592. shader: string;
  49593. };
  49594. }
  49595. declare module BABYLON {
  49596. /** @hidden */
  49597. export var glowMapMergeVertexShader: {
  49598. name: string;
  49599. shader: string;
  49600. };
  49601. }
  49602. declare module BABYLON {
  49603. interface AbstractScene {
  49604. /**
  49605. * Return a the first highlight layer of the scene with a given name.
  49606. * @param name The name of the highlight layer to look for.
  49607. * @return The highlight layer if found otherwise null.
  49608. */
  49609. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49610. }
  49611. /**
  49612. * Glow layer options. This helps customizing the behaviour
  49613. * of the glow layer.
  49614. */
  49615. export interface IGlowLayerOptions {
  49616. /**
  49617. * Multiplication factor apply to the canvas size to compute the render target size
  49618. * used to generated the glowing objects (the smaller the faster).
  49619. */
  49620. mainTextureRatio: number;
  49621. /**
  49622. * Enforces a fixed size texture to ensure resize independant blur.
  49623. */
  49624. mainTextureFixedSize?: number;
  49625. /**
  49626. * How big is the kernel of the blur texture.
  49627. */
  49628. blurKernelSize: number;
  49629. /**
  49630. * The camera attached to the layer.
  49631. */
  49632. camera: Nullable<Camera>;
  49633. /**
  49634. * Enable MSAA by chosing the number of samples.
  49635. */
  49636. mainTextureSamples?: number;
  49637. /**
  49638. * The rendering group to draw the layer in.
  49639. */
  49640. renderingGroupId: number;
  49641. }
  49642. /**
  49643. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49644. *
  49645. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49646. * glowy meshes to your scene.
  49647. *
  49648. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49649. */
  49650. export class GlowLayer extends EffectLayer {
  49651. /**
  49652. * Effect Name of the layer.
  49653. */
  49654. static readonly EffectName: string;
  49655. /**
  49656. * The default blur kernel size used for the glow.
  49657. */
  49658. static DefaultBlurKernelSize: number;
  49659. /**
  49660. * The default texture size ratio used for the glow.
  49661. */
  49662. static DefaultTextureRatio: number;
  49663. /**
  49664. * Sets the kernel size of the blur.
  49665. */
  49666. /**
  49667. * Gets the kernel size of the blur.
  49668. */
  49669. blurKernelSize: number;
  49670. /**
  49671. * Sets the glow intensity.
  49672. */
  49673. /**
  49674. * Gets the glow intensity.
  49675. */
  49676. intensity: number;
  49677. private _options;
  49678. private _intensity;
  49679. private _horizontalBlurPostprocess1;
  49680. private _verticalBlurPostprocess1;
  49681. private _horizontalBlurPostprocess2;
  49682. private _verticalBlurPostprocess2;
  49683. private _blurTexture1;
  49684. private _blurTexture2;
  49685. private _postProcesses1;
  49686. private _postProcesses2;
  49687. private _includedOnlyMeshes;
  49688. private _excludedMeshes;
  49689. /**
  49690. * Callback used to let the user override the color selection on a per mesh basis
  49691. */
  49692. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49693. /**
  49694. * Callback used to let the user override the texture selection on a per mesh basis
  49695. */
  49696. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49697. /**
  49698. * Instantiates a new glow Layer and references it to the scene.
  49699. * @param name The name of the layer
  49700. * @param scene The scene to use the layer in
  49701. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49702. */
  49703. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49704. /**
  49705. * Get the effect name of the layer.
  49706. * @return The effect name
  49707. */
  49708. getEffectName(): string;
  49709. /**
  49710. * Create the merge effect. This is the shader use to blit the information back
  49711. * to the main canvas at the end of the scene rendering.
  49712. */
  49713. protected _createMergeEffect(): Effect;
  49714. /**
  49715. * Creates the render target textures and post processes used in the glow layer.
  49716. */
  49717. protected _createTextureAndPostProcesses(): void;
  49718. /**
  49719. * Checks for the readiness of the element composing the layer.
  49720. * @param subMesh the mesh to check for
  49721. * @param useInstances specify wether or not to use instances to render the mesh
  49722. * @param emissiveTexture the associated emissive texture used to generate the glow
  49723. * @return true if ready otherwise, false
  49724. */
  49725. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49726. /**
  49727. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49728. */
  49729. needStencil(): boolean;
  49730. /**
  49731. * Returns true if the mesh can be rendered, otherwise false.
  49732. * @param mesh The mesh to render
  49733. * @param material The material used on the mesh
  49734. * @returns true if it can be rendered otherwise false
  49735. */
  49736. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49737. /**
  49738. * Implementation specific of rendering the generating effect on the main canvas.
  49739. * @param effect The effect used to render through
  49740. */
  49741. protected _internalRender(effect: Effect): void;
  49742. /**
  49743. * Sets the required values for both the emissive texture and and the main color.
  49744. */
  49745. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49746. /**
  49747. * Returns true if the mesh should render, otherwise false.
  49748. * @param mesh The mesh to render
  49749. * @returns true if it should render otherwise false
  49750. */
  49751. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49752. /**
  49753. * Adds specific effects defines.
  49754. * @param defines The defines to add specifics to.
  49755. */
  49756. protected _addCustomEffectDefines(defines: string[]): void;
  49757. /**
  49758. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49759. * @param mesh The mesh to exclude from the glow layer
  49760. */
  49761. addExcludedMesh(mesh: Mesh): void;
  49762. /**
  49763. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49764. * @param mesh The mesh to remove
  49765. */
  49766. removeExcludedMesh(mesh: Mesh): void;
  49767. /**
  49768. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49769. * @param mesh The mesh to include in the glow layer
  49770. */
  49771. addIncludedOnlyMesh(mesh: Mesh): void;
  49772. /**
  49773. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49774. * @param mesh The mesh to remove
  49775. */
  49776. removeIncludedOnlyMesh(mesh: Mesh): void;
  49777. /**
  49778. * Determine if a given mesh will be used in the glow layer
  49779. * @param mesh The mesh to test
  49780. * @returns true if the mesh will be highlighted by the current glow layer
  49781. */
  49782. hasMesh(mesh: AbstractMesh): boolean;
  49783. /**
  49784. * Free any resources and references associated to a mesh.
  49785. * Internal use
  49786. * @param mesh The mesh to free.
  49787. * @hidden
  49788. */
  49789. _disposeMesh(mesh: Mesh): void;
  49790. /**
  49791. * Gets the class name of the effect layer
  49792. * @returns the string with the class name of the effect layer
  49793. */
  49794. getClassName(): string;
  49795. /**
  49796. * Serializes this glow layer
  49797. * @returns a serialized glow layer object
  49798. */
  49799. serialize(): any;
  49800. /**
  49801. * Creates a Glow Layer from parsed glow layer data
  49802. * @param parsedGlowLayer defines glow layer data
  49803. * @param scene defines the current scene
  49804. * @param rootUrl defines the root URL containing the glow layer information
  49805. * @returns a parsed Glow Layer
  49806. */
  49807. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49808. }
  49809. }
  49810. declare module BABYLON {
  49811. /** @hidden */
  49812. export var glowBlurPostProcessPixelShader: {
  49813. name: string;
  49814. shader: string;
  49815. };
  49816. }
  49817. declare module BABYLON {
  49818. interface AbstractScene {
  49819. /**
  49820. * Return a the first highlight layer of the scene with a given name.
  49821. * @param name The name of the highlight layer to look for.
  49822. * @return The highlight layer if found otherwise null.
  49823. */
  49824. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49825. }
  49826. /**
  49827. * Highlight layer options. This helps customizing the behaviour
  49828. * of the highlight layer.
  49829. */
  49830. export interface IHighlightLayerOptions {
  49831. /**
  49832. * Multiplication factor apply to the canvas size to compute the render target size
  49833. * used to generated the glowing objects (the smaller the faster).
  49834. */
  49835. mainTextureRatio: number;
  49836. /**
  49837. * Enforces a fixed size texture to ensure resize independant blur.
  49838. */
  49839. mainTextureFixedSize?: number;
  49840. /**
  49841. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49842. * of the picture to blur (the smaller the faster).
  49843. */
  49844. blurTextureSizeRatio: number;
  49845. /**
  49846. * How big in texel of the blur texture is the vertical blur.
  49847. */
  49848. blurVerticalSize: number;
  49849. /**
  49850. * How big in texel of the blur texture is the horizontal blur.
  49851. */
  49852. blurHorizontalSize: number;
  49853. /**
  49854. * Alpha blending mode used to apply the blur. Default is combine.
  49855. */
  49856. alphaBlendingMode: number;
  49857. /**
  49858. * The camera attached to the layer.
  49859. */
  49860. camera: Nullable<Camera>;
  49861. /**
  49862. * Should we display highlight as a solid stroke?
  49863. */
  49864. isStroke?: boolean;
  49865. /**
  49866. * The rendering group to draw the layer in.
  49867. */
  49868. renderingGroupId: number;
  49869. }
  49870. /**
  49871. * The highlight layer Helps adding a glow effect around a mesh.
  49872. *
  49873. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49874. * glowy meshes to your scene.
  49875. *
  49876. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49877. */
  49878. export class HighlightLayer extends EffectLayer {
  49879. name: string;
  49880. /**
  49881. * Effect Name of the highlight layer.
  49882. */
  49883. static readonly EffectName: string;
  49884. /**
  49885. * The neutral color used during the preparation of the glow effect.
  49886. * This is black by default as the blend operation is a blend operation.
  49887. */
  49888. static NeutralColor: Color4;
  49889. /**
  49890. * Stencil value used for glowing meshes.
  49891. */
  49892. static GlowingMeshStencilReference: number;
  49893. /**
  49894. * Stencil value used for the other meshes in the scene.
  49895. */
  49896. static NormalMeshStencilReference: number;
  49897. /**
  49898. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49899. */
  49900. innerGlow: boolean;
  49901. /**
  49902. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49903. */
  49904. outerGlow: boolean;
  49905. /**
  49906. * Specifies the horizontal size of the blur.
  49907. */
  49908. /**
  49909. * Gets the horizontal size of the blur.
  49910. */
  49911. blurHorizontalSize: number;
  49912. /**
  49913. * Specifies the vertical size of the blur.
  49914. */
  49915. /**
  49916. * Gets the vertical size of the blur.
  49917. */
  49918. blurVerticalSize: number;
  49919. /**
  49920. * An event triggered when the highlight layer is being blurred.
  49921. */
  49922. onBeforeBlurObservable: Observable<HighlightLayer>;
  49923. /**
  49924. * An event triggered when the highlight layer has been blurred.
  49925. */
  49926. onAfterBlurObservable: Observable<HighlightLayer>;
  49927. private _instanceGlowingMeshStencilReference;
  49928. private _options;
  49929. private _downSamplePostprocess;
  49930. private _horizontalBlurPostprocess;
  49931. private _verticalBlurPostprocess;
  49932. private _blurTexture;
  49933. private _meshes;
  49934. private _excludedMeshes;
  49935. /**
  49936. * Instantiates a new highlight Layer and references it to the scene..
  49937. * @param name The name of the layer
  49938. * @param scene The scene to use the layer in
  49939. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49940. */
  49941. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49942. /**
  49943. * Get the effect name of the layer.
  49944. * @return The effect name
  49945. */
  49946. getEffectName(): string;
  49947. /**
  49948. * Create the merge effect. This is the shader use to blit the information back
  49949. * to the main canvas at the end of the scene rendering.
  49950. */
  49951. protected _createMergeEffect(): Effect;
  49952. /**
  49953. * Creates the render target textures and post processes used in the highlight layer.
  49954. */
  49955. protected _createTextureAndPostProcesses(): void;
  49956. /**
  49957. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49958. */
  49959. needStencil(): boolean;
  49960. /**
  49961. * Checks for the readiness of the element composing the layer.
  49962. * @param subMesh the mesh to check for
  49963. * @param useInstances specify wether or not to use instances to render the mesh
  49964. * @param emissiveTexture the associated emissive texture used to generate the glow
  49965. * @return true if ready otherwise, false
  49966. */
  49967. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49968. /**
  49969. * Implementation specific of rendering the generating effect on the main canvas.
  49970. * @param effect The effect used to render through
  49971. */
  49972. protected _internalRender(effect: Effect): void;
  49973. /**
  49974. * Returns true if the layer contains information to display, otherwise false.
  49975. */
  49976. shouldRender(): boolean;
  49977. /**
  49978. * Returns true if the mesh should render, otherwise false.
  49979. * @param mesh The mesh to render
  49980. * @returns true if it should render otherwise false
  49981. */
  49982. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49983. /**
  49984. * Sets the required values for both the emissive texture and and the main color.
  49985. */
  49986. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49987. /**
  49988. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49989. * @param mesh The mesh to exclude from the highlight layer
  49990. */
  49991. addExcludedMesh(mesh: Mesh): void;
  49992. /**
  49993. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49994. * @param mesh The mesh to highlight
  49995. */
  49996. removeExcludedMesh(mesh: Mesh): void;
  49997. /**
  49998. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49999. * @param mesh mesh to test
  50000. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50001. */
  50002. hasMesh(mesh: AbstractMesh): boolean;
  50003. /**
  50004. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50005. * @param mesh The mesh to highlight
  50006. * @param color The color of the highlight
  50007. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50008. */
  50009. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50010. /**
  50011. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50012. * @param mesh The mesh to highlight
  50013. */
  50014. removeMesh(mesh: Mesh): void;
  50015. /**
  50016. * Force the stencil to the normal expected value for none glowing parts
  50017. */
  50018. private _defaultStencilReference;
  50019. /**
  50020. * Free any resources and references associated to a mesh.
  50021. * Internal use
  50022. * @param mesh The mesh to free.
  50023. * @hidden
  50024. */
  50025. _disposeMesh(mesh: Mesh): void;
  50026. /**
  50027. * Dispose the highlight layer and free resources.
  50028. */
  50029. dispose(): void;
  50030. /**
  50031. * Gets the class name of the effect layer
  50032. * @returns the string with the class name of the effect layer
  50033. */
  50034. getClassName(): string;
  50035. /**
  50036. * Serializes this Highlight layer
  50037. * @returns a serialized Highlight layer object
  50038. */
  50039. serialize(): any;
  50040. /**
  50041. * Creates a Highlight layer from parsed Highlight layer data
  50042. * @param parsedHightlightLayer defines the Highlight layer data
  50043. * @param scene defines the current scene
  50044. * @param rootUrl defines the root URL containing the Highlight layer information
  50045. * @returns a parsed Highlight layer
  50046. */
  50047. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50048. }
  50049. }
  50050. declare module BABYLON {
  50051. interface AbstractScene {
  50052. /**
  50053. * The list of layers (background and foreground) of the scene
  50054. */
  50055. layers: Array<Layer>;
  50056. }
  50057. /**
  50058. * Defines the layer scene component responsible to manage any layers
  50059. * in a given scene.
  50060. */
  50061. export class LayerSceneComponent implements ISceneComponent {
  50062. /**
  50063. * The component name helpfull to identify the component in the list of scene components.
  50064. */
  50065. readonly name: string;
  50066. /**
  50067. * The scene the component belongs to.
  50068. */
  50069. scene: Scene;
  50070. private _engine;
  50071. /**
  50072. * Creates a new instance of the component for the given scene
  50073. * @param scene Defines the scene to register the component in
  50074. */
  50075. constructor(scene: Scene);
  50076. /**
  50077. * Registers the component in a given scene
  50078. */
  50079. register(): void;
  50080. /**
  50081. * Rebuilds the elements related to this component in case of
  50082. * context lost for instance.
  50083. */
  50084. rebuild(): void;
  50085. /**
  50086. * Disposes the component and the associated ressources.
  50087. */
  50088. dispose(): void;
  50089. private _draw;
  50090. private _drawCameraPredicate;
  50091. private _drawCameraBackground;
  50092. private _drawCameraForeground;
  50093. private _drawRenderTargetPredicate;
  50094. private _drawRenderTargetBackground;
  50095. private _drawRenderTargetForeground;
  50096. /**
  50097. * Adds all the elements from the container to the scene
  50098. * @param container the container holding the elements
  50099. */
  50100. addFromContainer(container: AbstractScene): void;
  50101. /**
  50102. * Removes all the elements in the container from the scene
  50103. * @param container contains the elements to remove
  50104. * @param dispose if the removed element should be disposed (default: false)
  50105. */
  50106. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50107. }
  50108. }
  50109. declare module BABYLON {
  50110. /** @hidden */
  50111. export var layerPixelShader: {
  50112. name: string;
  50113. shader: string;
  50114. };
  50115. }
  50116. declare module BABYLON {
  50117. /** @hidden */
  50118. export var layerVertexShader: {
  50119. name: string;
  50120. shader: string;
  50121. };
  50122. }
  50123. declare module BABYLON {
  50124. /**
  50125. * This represents a full screen 2d layer.
  50126. * This can be useful to display a picture in the background of your scene for instance.
  50127. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50128. */
  50129. export class Layer {
  50130. /**
  50131. * Define the name of the layer.
  50132. */
  50133. name: string;
  50134. /**
  50135. * Define the texture the layer should display.
  50136. */
  50137. texture: Nullable<Texture>;
  50138. /**
  50139. * Is the layer in background or foreground.
  50140. */
  50141. isBackground: boolean;
  50142. /**
  50143. * Define the color of the layer (instead of texture).
  50144. */
  50145. color: Color4;
  50146. /**
  50147. * Define the scale of the layer in order to zoom in out of the texture.
  50148. */
  50149. scale: Vector2;
  50150. /**
  50151. * Define an offset for the layer in order to shift the texture.
  50152. */
  50153. offset: Vector2;
  50154. /**
  50155. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50156. */
  50157. alphaBlendingMode: number;
  50158. /**
  50159. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50160. * Alpha test will not mix with the background color in case of transparency.
  50161. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50162. */
  50163. alphaTest: boolean;
  50164. /**
  50165. * Define a mask to restrict the layer to only some of the scene cameras.
  50166. */
  50167. layerMask: number;
  50168. /**
  50169. * Define the list of render target the layer is visible into.
  50170. */
  50171. renderTargetTextures: RenderTargetTexture[];
  50172. /**
  50173. * Define if the layer is only used in renderTarget or if it also
  50174. * renders in the main frame buffer of the canvas.
  50175. */
  50176. renderOnlyInRenderTargetTextures: boolean;
  50177. private _scene;
  50178. private _vertexBuffers;
  50179. private _indexBuffer;
  50180. private _effect;
  50181. private _alphaTestEffect;
  50182. /**
  50183. * An event triggered when the layer is disposed.
  50184. */
  50185. onDisposeObservable: Observable<Layer>;
  50186. private _onDisposeObserver;
  50187. /**
  50188. * Back compatibility with callback before the onDisposeObservable existed.
  50189. * The set callback will be triggered when the layer has been disposed.
  50190. */
  50191. onDispose: () => void;
  50192. /**
  50193. * An event triggered before rendering the scene
  50194. */
  50195. onBeforeRenderObservable: Observable<Layer>;
  50196. private _onBeforeRenderObserver;
  50197. /**
  50198. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50199. * The set callback will be triggered just before rendering the layer.
  50200. */
  50201. onBeforeRender: () => void;
  50202. /**
  50203. * An event triggered after rendering the scene
  50204. */
  50205. onAfterRenderObservable: Observable<Layer>;
  50206. private _onAfterRenderObserver;
  50207. /**
  50208. * Back compatibility with callback before the onAfterRenderObservable existed.
  50209. * The set callback will be triggered just after rendering the layer.
  50210. */
  50211. onAfterRender: () => void;
  50212. /**
  50213. * Instantiates a new layer.
  50214. * This represents a full screen 2d layer.
  50215. * This can be useful to display a picture in the background of your scene for instance.
  50216. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50217. * @param name Define the name of the layer in the scene
  50218. * @param imgUrl Define the url of the texture to display in the layer
  50219. * @param scene Define the scene the layer belongs to
  50220. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50221. * @param color Defines a color for the layer
  50222. */
  50223. constructor(
  50224. /**
  50225. * Define the name of the layer.
  50226. */
  50227. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50228. private _createIndexBuffer;
  50229. /** @hidden */
  50230. _rebuild(): void;
  50231. /**
  50232. * Renders the layer in the scene.
  50233. */
  50234. render(): void;
  50235. /**
  50236. * Disposes and releases the associated ressources.
  50237. */
  50238. dispose(): void;
  50239. }
  50240. }
  50241. declare module BABYLON {
  50242. /** @hidden */
  50243. export var lensFlarePixelShader: {
  50244. name: string;
  50245. shader: string;
  50246. };
  50247. }
  50248. declare module BABYLON {
  50249. /** @hidden */
  50250. export var lensFlareVertexShader: {
  50251. name: string;
  50252. shader: string;
  50253. };
  50254. }
  50255. declare module BABYLON {
  50256. /**
  50257. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50258. * It is usually composed of several `lensFlare`.
  50259. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50260. */
  50261. export class LensFlareSystem {
  50262. /**
  50263. * Define the name of the lens flare system
  50264. */
  50265. name: string;
  50266. /**
  50267. * List of lens flares used in this system.
  50268. */
  50269. lensFlares: LensFlare[];
  50270. /**
  50271. * Define a limit from the border the lens flare can be visible.
  50272. */
  50273. borderLimit: number;
  50274. /**
  50275. * Define a viewport border we do not want to see the lens flare in.
  50276. */
  50277. viewportBorder: number;
  50278. /**
  50279. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50280. */
  50281. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50282. /**
  50283. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50284. */
  50285. layerMask: number;
  50286. /**
  50287. * Define the id of the lens flare system in the scene.
  50288. * (equal to name by default)
  50289. */
  50290. id: string;
  50291. private _scene;
  50292. private _emitter;
  50293. private _vertexBuffers;
  50294. private _indexBuffer;
  50295. private _effect;
  50296. private _positionX;
  50297. private _positionY;
  50298. private _isEnabled;
  50299. /** @hidden */
  50300. static _SceneComponentInitialization: (scene: Scene) => void;
  50301. /**
  50302. * Instantiates a lens flare system.
  50303. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50304. * It is usually composed of several `lensFlare`.
  50305. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50306. * @param name Define the name of the lens flare system in the scene
  50307. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50308. * @param scene Define the scene the lens flare system belongs to
  50309. */
  50310. constructor(
  50311. /**
  50312. * Define the name of the lens flare system
  50313. */
  50314. name: string, emitter: any, scene: Scene);
  50315. /**
  50316. * Define if the lens flare system is enabled.
  50317. */
  50318. isEnabled: boolean;
  50319. /**
  50320. * Get the scene the effects belongs to.
  50321. * @returns the scene holding the lens flare system
  50322. */
  50323. getScene(): Scene;
  50324. /**
  50325. * Get the emitter of the lens flare system.
  50326. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50327. * @returns the emitter of the lens flare system
  50328. */
  50329. getEmitter(): any;
  50330. /**
  50331. * Set the emitter of the lens flare system.
  50332. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50333. * @param newEmitter Define the new emitter of the system
  50334. */
  50335. setEmitter(newEmitter: any): void;
  50336. /**
  50337. * Get the lens flare system emitter position.
  50338. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50339. * @returns the position
  50340. */
  50341. getEmitterPosition(): Vector3;
  50342. /**
  50343. * @hidden
  50344. */
  50345. computeEffectivePosition(globalViewport: Viewport): boolean;
  50346. /** @hidden */
  50347. _isVisible(): boolean;
  50348. /**
  50349. * @hidden
  50350. */
  50351. render(): boolean;
  50352. /**
  50353. * Dispose and release the lens flare with its associated resources.
  50354. */
  50355. dispose(): void;
  50356. /**
  50357. * Parse a lens flare system from a JSON repressentation
  50358. * @param parsedLensFlareSystem Define the JSON to parse
  50359. * @param scene Define the scene the parsed system should be instantiated in
  50360. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50361. * @returns the parsed system
  50362. */
  50363. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50364. /**
  50365. * Serialize the current Lens Flare System into a JSON representation.
  50366. * @returns the serialized JSON
  50367. */
  50368. serialize(): any;
  50369. }
  50370. }
  50371. declare module BABYLON {
  50372. /**
  50373. * This represents one of the lens effect in a `lensFlareSystem`.
  50374. * It controls one of the indiviual texture used in the effect.
  50375. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50376. */
  50377. export class LensFlare {
  50378. /**
  50379. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50380. */
  50381. size: number;
  50382. /**
  50383. * 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.
  50384. */
  50385. position: number;
  50386. /**
  50387. * Define the lens color.
  50388. */
  50389. color: Color3;
  50390. /**
  50391. * Define the lens texture.
  50392. */
  50393. texture: Nullable<Texture>;
  50394. /**
  50395. * Define the alpha mode to render this particular lens.
  50396. */
  50397. alphaMode: number;
  50398. private _system;
  50399. /**
  50400. * Creates a new Lens Flare.
  50401. * This represents one of the lens effect in a `lensFlareSystem`.
  50402. * It controls one of the indiviual texture used in the effect.
  50403. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50404. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50405. * @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.
  50406. * @param color Define the lens color
  50407. * @param imgUrl Define the lens texture url
  50408. * @param system Define the `lensFlareSystem` this flare is part of
  50409. * @returns The newly created Lens Flare
  50410. */
  50411. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50412. /**
  50413. * Instantiates a new Lens Flare.
  50414. * This represents one of the lens effect in a `lensFlareSystem`.
  50415. * It controls one of the indiviual texture used in the effect.
  50416. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50417. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50418. * @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.
  50419. * @param color Define the lens color
  50420. * @param imgUrl Define the lens texture url
  50421. * @param system Define the `lensFlareSystem` this flare is part of
  50422. */
  50423. constructor(
  50424. /**
  50425. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50426. */
  50427. size: number,
  50428. /**
  50429. * 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.
  50430. */
  50431. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50432. /**
  50433. * Dispose and release the lens flare with its associated resources.
  50434. */
  50435. dispose(): void;
  50436. }
  50437. }
  50438. declare module BABYLON {
  50439. interface AbstractScene {
  50440. /**
  50441. * The list of lens flare system added to the scene
  50442. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50443. */
  50444. lensFlareSystems: Array<LensFlareSystem>;
  50445. /**
  50446. * Removes the given lens flare system from this scene.
  50447. * @param toRemove The lens flare system to remove
  50448. * @returns The index of the removed lens flare system
  50449. */
  50450. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50451. /**
  50452. * Adds the given lens flare system to this scene
  50453. * @param newLensFlareSystem The lens flare system to add
  50454. */
  50455. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50456. /**
  50457. * Gets a lens flare system using its name
  50458. * @param name defines the name to look for
  50459. * @returns the lens flare system or null if not found
  50460. */
  50461. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50462. /**
  50463. * Gets a lens flare system using its id
  50464. * @param id defines the id to look for
  50465. * @returns the lens flare system or null if not found
  50466. */
  50467. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50468. }
  50469. /**
  50470. * Defines the lens flare scene component responsible to manage any lens flares
  50471. * in a given scene.
  50472. */
  50473. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50474. /**
  50475. * The component name helpfull to identify the component in the list of scene components.
  50476. */
  50477. readonly name: string;
  50478. /**
  50479. * The scene the component belongs to.
  50480. */
  50481. scene: Scene;
  50482. /**
  50483. * Creates a new instance of the component for the given scene
  50484. * @param scene Defines the scene to register the component in
  50485. */
  50486. constructor(scene: Scene);
  50487. /**
  50488. * Registers the component in a given scene
  50489. */
  50490. register(): void;
  50491. /**
  50492. * Rebuilds the elements related to this component in case of
  50493. * context lost for instance.
  50494. */
  50495. rebuild(): void;
  50496. /**
  50497. * Adds all the elements from the container to the scene
  50498. * @param container the container holding the elements
  50499. */
  50500. addFromContainer(container: AbstractScene): void;
  50501. /**
  50502. * Removes all the elements in the container from the scene
  50503. * @param container contains the elements to remove
  50504. * @param dispose if the removed element should be disposed (default: false)
  50505. */
  50506. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50507. /**
  50508. * Serializes the component data to the specified json object
  50509. * @param serializationObject The object to serialize to
  50510. */
  50511. serialize(serializationObject: any): void;
  50512. /**
  50513. * Disposes the component and the associated ressources.
  50514. */
  50515. dispose(): void;
  50516. private _draw;
  50517. }
  50518. }
  50519. declare module BABYLON {
  50520. /**
  50521. * Defines the shadow generator component responsible to manage any shadow generators
  50522. * in a given scene.
  50523. */
  50524. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50525. /**
  50526. * The component name helpfull to identify the component in the list of scene components.
  50527. */
  50528. readonly name: string;
  50529. /**
  50530. * The scene the component belongs to.
  50531. */
  50532. scene: Scene;
  50533. /**
  50534. * Creates a new instance of the component for the given scene
  50535. * @param scene Defines the scene to register the component in
  50536. */
  50537. constructor(scene: Scene);
  50538. /**
  50539. * Registers the component in a given scene
  50540. */
  50541. register(): void;
  50542. /**
  50543. * Rebuilds the elements related to this component in case of
  50544. * context lost for instance.
  50545. */
  50546. rebuild(): void;
  50547. /**
  50548. * Serializes the component data to the specified json object
  50549. * @param serializationObject The object to serialize to
  50550. */
  50551. serialize(serializationObject: any): void;
  50552. /**
  50553. * Adds all the elements from the container to the scene
  50554. * @param container the container holding the elements
  50555. */
  50556. addFromContainer(container: AbstractScene): void;
  50557. /**
  50558. * Removes all the elements in the container from the scene
  50559. * @param container contains the elements to remove
  50560. * @param dispose if the removed element should be disposed (default: false)
  50561. */
  50562. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50563. /**
  50564. * Rebuilds the elements related to this component in case of
  50565. * context lost for instance.
  50566. */
  50567. dispose(): void;
  50568. private _gatherRenderTargets;
  50569. }
  50570. }
  50571. declare module BABYLON {
  50572. /**
  50573. * A point light is a light defined by an unique point in world space.
  50574. * The light is emitted in every direction from this point.
  50575. * A good example of a point light is a standard light bulb.
  50576. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50577. */
  50578. export class PointLight extends ShadowLight {
  50579. private _shadowAngle;
  50580. /**
  50581. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50582. * This specifies what angle the shadow will use to be created.
  50583. *
  50584. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50585. */
  50586. /**
  50587. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50588. * This specifies what angle the shadow will use to be created.
  50589. *
  50590. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50591. */
  50592. shadowAngle: number;
  50593. /**
  50594. * Gets the direction if it has been set.
  50595. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50596. */
  50597. /**
  50598. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50599. */
  50600. direction: Vector3;
  50601. /**
  50602. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50603. * A PointLight emits the light in every direction.
  50604. * It can cast shadows.
  50605. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50606. * ```javascript
  50607. * var pointLight = new PointLight("pl", camera.position, scene);
  50608. * ```
  50609. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50610. * @param name The light friendly name
  50611. * @param position The position of the point light in the scene
  50612. * @param scene The scene the lights belongs to
  50613. */
  50614. constructor(name: string, position: Vector3, scene: Scene);
  50615. /**
  50616. * Returns the string "PointLight"
  50617. * @returns the class name
  50618. */
  50619. getClassName(): string;
  50620. /**
  50621. * Returns the integer 0.
  50622. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50623. */
  50624. getTypeID(): number;
  50625. /**
  50626. * Specifies wether or not the shadowmap should be a cube texture.
  50627. * @returns true if the shadowmap needs to be a cube texture.
  50628. */
  50629. needCube(): boolean;
  50630. /**
  50631. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50632. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50633. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50634. */
  50635. getShadowDirection(faceIndex?: number): Vector3;
  50636. /**
  50637. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50638. * - fov = PI / 2
  50639. * - aspect ratio : 1.0
  50640. * - z-near and far equal to the active camera minZ and maxZ.
  50641. * Returns the PointLight.
  50642. */
  50643. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50644. protected _buildUniformLayout(): void;
  50645. /**
  50646. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50647. * @param effect The effect to update
  50648. * @param lightIndex The index of the light in the effect to update
  50649. * @returns The point light
  50650. */
  50651. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50652. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50653. /**
  50654. * Prepares the list of defines specific to the light type.
  50655. * @param defines the list of defines
  50656. * @param lightIndex defines the index of the light for the effect
  50657. */
  50658. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50659. }
  50660. }
  50661. declare module BABYLON {
  50662. /**
  50663. * Header information of HDR texture files.
  50664. */
  50665. export interface HDRInfo {
  50666. /**
  50667. * The height of the texture in pixels.
  50668. */
  50669. height: number;
  50670. /**
  50671. * The width of the texture in pixels.
  50672. */
  50673. width: number;
  50674. /**
  50675. * The index of the beginning of the data in the binary file.
  50676. */
  50677. dataPosition: number;
  50678. }
  50679. /**
  50680. * This groups tools to convert HDR texture to native colors array.
  50681. */
  50682. export class HDRTools {
  50683. private static Ldexp;
  50684. private static Rgbe2float;
  50685. private static readStringLine;
  50686. /**
  50687. * Reads header information from an RGBE texture stored in a native array.
  50688. * More information on this format are available here:
  50689. * https://en.wikipedia.org/wiki/RGBE_image_format
  50690. *
  50691. * @param uint8array The binary file stored in native array.
  50692. * @return The header information.
  50693. */
  50694. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50695. /**
  50696. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50697. * This RGBE texture needs to store the information as a panorama.
  50698. *
  50699. * More information on this format are available here:
  50700. * https://en.wikipedia.org/wiki/RGBE_image_format
  50701. *
  50702. * @param buffer The binary file stored in an array buffer.
  50703. * @param size The expected size of the extracted cubemap.
  50704. * @return The Cube Map information.
  50705. */
  50706. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50707. /**
  50708. * Returns the pixels data extracted from an RGBE texture.
  50709. * This pixels will be stored left to right up to down in the R G B order in one array.
  50710. *
  50711. * More information on this format are available here:
  50712. * https://en.wikipedia.org/wiki/RGBE_image_format
  50713. *
  50714. * @param uint8array The binary file stored in an array buffer.
  50715. * @param hdrInfo The header information of the file.
  50716. * @return The pixels data in RGB right to left up to down order.
  50717. */
  50718. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50719. private static RGBE_ReadPixels_RLE;
  50720. }
  50721. }
  50722. declare module BABYLON {
  50723. /**
  50724. * This represents a texture coming from an HDR input.
  50725. *
  50726. * The only supported format is currently panorama picture stored in RGBE format.
  50727. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50728. */
  50729. export class HDRCubeTexture extends BaseTexture {
  50730. private static _facesMapping;
  50731. private _generateHarmonics;
  50732. private _noMipmap;
  50733. private _textureMatrix;
  50734. private _size;
  50735. private _onLoad;
  50736. private _onError;
  50737. /**
  50738. * The texture URL.
  50739. */
  50740. url: string;
  50741. /**
  50742. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50743. */
  50744. coordinatesMode: number;
  50745. protected _isBlocking: boolean;
  50746. /**
  50747. * Sets wether or not the texture is blocking during loading.
  50748. */
  50749. /**
  50750. * Gets wether or not the texture is blocking during loading.
  50751. */
  50752. isBlocking: boolean;
  50753. protected _rotationY: number;
  50754. /**
  50755. * Sets texture matrix rotation angle around Y axis in radians.
  50756. */
  50757. /**
  50758. * Gets texture matrix rotation angle around Y axis radians.
  50759. */
  50760. rotationY: number;
  50761. /**
  50762. * Gets or sets the center of the bounding box associated with the cube texture
  50763. * It must define where the camera used to render the texture was set
  50764. */
  50765. boundingBoxPosition: Vector3;
  50766. private _boundingBoxSize;
  50767. /**
  50768. * Gets or sets the size of the bounding box associated with the cube texture
  50769. * When defined, the cubemap will switch to local mode
  50770. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50771. * @example https://www.babylonjs-playground.com/#RNASML
  50772. */
  50773. boundingBoxSize: Vector3;
  50774. /**
  50775. * Instantiates an HDRTexture from the following parameters.
  50776. *
  50777. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50778. * @param scene The scene the texture will be used in
  50779. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50780. * @param noMipmap Forces to not generate the mipmap if true
  50781. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50782. * @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)
  50783. * @param reserved Reserved flag for internal use.
  50784. */
  50785. 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>);
  50786. /**
  50787. * Get the current class name of the texture useful for serialization or dynamic coding.
  50788. * @returns "HDRCubeTexture"
  50789. */
  50790. getClassName(): string;
  50791. /**
  50792. * Occurs when the file is raw .hdr file.
  50793. */
  50794. private loadTexture;
  50795. clone(): HDRCubeTexture;
  50796. delayLoad(): void;
  50797. /**
  50798. * Get the texture reflection matrix used to rotate/transform the reflection.
  50799. * @returns the reflection matrix
  50800. */
  50801. getReflectionTextureMatrix(): Matrix;
  50802. /**
  50803. * Set the texture reflection matrix used to rotate/transform the reflection.
  50804. * @param value Define the reflection matrix to set
  50805. */
  50806. setReflectionTextureMatrix(value: Matrix): void;
  50807. /**
  50808. * Parses a JSON representation of an HDR Texture in order to create the texture
  50809. * @param parsedTexture Define the JSON representation
  50810. * @param scene Define the scene the texture should be created in
  50811. * @param rootUrl Define the root url in case we need to load relative dependencies
  50812. * @returns the newly created texture after parsing
  50813. */
  50814. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50815. serialize(): any;
  50816. }
  50817. }
  50818. declare module BABYLON {
  50819. /**
  50820. * Class used to control physics engine
  50821. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50822. */
  50823. export class PhysicsEngine implements IPhysicsEngine {
  50824. private _physicsPlugin;
  50825. /**
  50826. * Global value used to control the smallest number supported by the simulation
  50827. */
  50828. static Epsilon: number;
  50829. private _impostors;
  50830. private _joints;
  50831. /**
  50832. * Gets the gravity vector used by the simulation
  50833. */
  50834. gravity: Vector3;
  50835. /**
  50836. * Factory used to create the default physics plugin.
  50837. * @returns The default physics plugin
  50838. */
  50839. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50840. /**
  50841. * Creates a new Physics Engine
  50842. * @param gravity defines the gravity vector used by the simulation
  50843. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50844. */
  50845. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50846. /**
  50847. * Sets the gravity vector used by the simulation
  50848. * @param gravity defines the gravity vector to use
  50849. */
  50850. setGravity(gravity: Vector3): void;
  50851. /**
  50852. * Set the time step of the physics engine.
  50853. * Default is 1/60.
  50854. * To slow it down, enter 1/600 for example.
  50855. * To speed it up, 1/30
  50856. * @param newTimeStep defines the new timestep to apply to this world.
  50857. */
  50858. setTimeStep(newTimeStep?: number): void;
  50859. /**
  50860. * Get the time step of the physics engine.
  50861. * @returns the current time step
  50862. */
  50863. getTimeStep(): number;
  50864. /**
  50865. * Release all resources
  50866. */
  50867. dispose(): void;
  50868. /**
  50869. * Gets the name of the current physics plugin
  50870. * @returns the name of the plugin
  50871. */
  50872. getPhysicsPluginName(): string;
  50873. /**
  50874. * Adding a new impostor for the impostor tracking.
  50875. * This will be done by the impostor itself.
  50876. * @param impostor the impostor to add
  50877. */
  50878. addImpostor(impostor: PhysicsImpostor): void;
  50879. /**
  50880. * Remove an impostor from the engine.
  50881. * This impostor and its mesh will not longer be updated by the physics engine.
  50882. * @param impostor the impostor to remove
  50883. */
  50884. removeImpostor(impostor: PhysicsImpostor): void;
  50885. /**
  50886. * Add a joint to the physics engine
  50887. * @param mainImpostor defines the main impostor to which the joint is added.
  50888. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50889. * @param joint defines the joint that will connect both impostors.
  50890. */
  50891. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50892. /**
  50893. * Removes a joint from the simulation
  50894. * @param mainImpostor defines the impostor used with the joint
  50895. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50896. * @param joint defines the joint to remove
  50897. */
  50898. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50899. /**
  50900. * Called by the scene. No need to call it.
  50901. * @param delta defines the timespam between frames
  50902. */
  50903. _step(delta: number): void;
  50904. /**
  50905. * Gets the current plugin used to run the simulation
  50906. * @returns current plugin
  50907. */
  50908. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50909. /**
  50910. * Gets the list of physic impostors
  50911. * @returns an array of PhysicsImpostor
  50912. */
  50913. getImpostors(): Array<PhysicsImpostor>;
  50914. /**
  50915. * Gets the impostor for a physics enabled object
  50916. * @param object defines the object impersonated by the impostor
  50917. * @returns the PhysicsImpostor or null if not found
  50918. */
  50919. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50920. /**
  50921. * Gets the impostor for a physics body object
  50922. * @param body defines physics body used by the impostor
  50923. * @returns the PhysicsImpostor or null if not found
  50924. */
  50925. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50926. /**
  50927. * Does a raycast in the physics world
  50928. * @param from when should the ray start?
  50929. * @param to when should the ray end?
  50930. * @returns PhysicsRaycastResult
  50931. */
  50932. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50933. }
  50934. }
  50935. declare module BABYLON {
  50936. /** @hidden */
  50937. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50938. private _useDeltaForWorldStep;
  50939. world: any;
  50940. name: string;
  50941. private _physicsMaterials;
  50942. private _fixedTimeStep;
  50943. private _cannonRaycastResult;
  50944. private _raycastResult;
  50945. private _physicsBodysToRemoveAfterStep;
  50946. BJSCANNON: any;
  50947. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50948. setGravity(gravity: Vector3): void;
  50949. setTimeStep(timeStep: number): void;
  50950. getTimeStep(): number;
  50951. executeStep(delta: number): void;
  50952. private _removeMarkedPhysicsBodiesFromWorld;
  50953. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50954. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50955. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50956. private _processChildMeshes;
  50957. removePhysicsBody(impostor: PhysicsImpostor): void;
  50958. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50959. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50960. private _addMaterial;
  50961. private _checkWithEpsilon;
  50962. private _createShape;
  50963. private _createHeightmap;
  50964. private _minus90X;
  50965. private _plus90X;
  50966. private _tmpPosition;
  50967. private _tmpDeltaPosition;
  50968. private _tmpUnityRotation;
  50969. private _updatePhysicsBodyTransformation;
  50970. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50971. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50972. isSupported(): boolean;
  50973. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50974. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50975. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50976. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50977. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50978. getBodyMass(impostor: PhysicsImpostor): number;
  50979. getBodyFriction(impostor: PhysicsImpostor): number;
  50980. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50981. getBodyRestitution(impostor: PhysicsImpostor): number;
  50982. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50983. sleepBody(impostor: PhysicsImpostor): void;
  50984. wakeUpBody(impostor: PhysicsImpostor): void;
  50985. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50986. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50987. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50988. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50989. getRadius(impostor: PhysicsImpostor): number;
  50990. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50991. dispose(): void;
  50992. private _extendNamespace;
  50993. /**
  50994. * Does a raycast in the physics world
  50995. * @param from when should the ray start?
  50996. * @param to when should the ray end?
  50997. * @returns PhysicsRaycastResult
  50998. */
  50999. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51000. }
  51001. }
  51002. declare module BABYLON {
  51003. /** @hidden */
  51004. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51005. world: any;
  51006. name: string;
  51007. BJSOIMO: any;
  51008. private _raycastResult;
  51009. constructor(iterations?: number, oimoInjection?: any);
  51010. setGravity(gravity: Vector3): void;
  51011. setTimeStep(timeStep: number): void;
  51012. getTimeStep(): number;
  51013. private _tmpImpostorsArray;
  51014. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51015. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51016. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51017. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51018. private _tmpPositionVector;
  51019. removePhysicsBody(impostor: PhysicsImpostor): void;
  51020. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51021. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51022. isSupported(): boolean;
  51023. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51024. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51025. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51026. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51027. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51028. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51029. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51030. getBodyMass(impostor: PhysicsImpostor): number;
  51031. getBodyFriction(impostor: PhysicsImpostor): number;
  51032. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51033. getBodyRestitution(impostor: PhysicsImpostor): number;
  51034. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51035. sleepBody(impostor: PhysicsImpostor): void;
  51036. wakeUpBody(impostor: PhysicsImpostor): void;
  51037. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51038. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51039. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51040. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51041. getRadius(impostor: PhysicsImpostor): number;
  51042. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51043. dispose(): void;
  51044. /**
  51045. * Does a raycast in the physics world
  51046. * @param from when should the ray start?
  51047. * @param to when should the ray end?
  51048. * @returns PhysicsRaycastResult
  51049. */
  51050. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51051. }
  51052. }
  51053. declare module BABYLON {
  51054. /**
  51055. * Class containing static functions to help procedurally build meshes
  51056. */
  51057. export class RibbonBuilder {
  51058. /**
  51059. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51060. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51061. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51062. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51063. * * 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
  51064. * * 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
  51065. * * 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
  51066. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51067. * * 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
  51068. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51069. * * 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
  51070. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51071. * * 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
  51072. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51074. * @param name defines the name of the mesh
  51075. * @param options defines the options used to create the mesh
  51076. * @param scene defines the hosting scene
  51077. * @returns the ribbon mesh
  51078. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51079. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51080. */
  51081. static CreateRibbon(name: string, options: {
  51082. pathArray: Vector3[][];
  51083. closeArray?: boolean;
  51084. closePath?: boolean;
  51085. offset?: number;
  51086. updatable?: boolean;
  51087. sideOrientation?: number;
  51088. frontUVs?: Vector4;
  51089. backUVs?: Vector4;
  51090. instance?: Mesh;
  51091. invertUV?: boolean;
  51092. uvs?: Vector2[];
  51093. colors?: Color4[];
  51094. }, scene?: Nullable<Scene>): Mesh;
  51095. }
  51096. }
  51097. declare module BABYLON {
  51098. /**
  51099. * Class containing static functions to help procedurally build meshes
  51100. */
  51101. export class ShapeBuilder {
  51102. /**
  51103. * 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.
  51104. * * 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.
  51105. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51106. * * 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.
  51107. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51108. * * 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
  51109. * * 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
  51110. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51112. * * 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
  51113. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51115. * @param name defines the name of the mesh
  51116. * @param options defines the options used to create the mesh
  51117. * @param scene defines the hosting scene
  51118. * @returns the extruded shape mesh
  51119. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51120. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51121. */
  51122. static ExtrudeShape(name: string, options: {
  51123. shape: Vector3[];
  51124. path: Vector3[];
  51125. scale?: number;
  51126. rotation?: number;
  51127. cap?: number;
  51128. updatable?: boolean;
  51129. sideOrientation?: number;
  51130. frontUVs?: Vector4;
  51131. backUVs?: Vector4;
  51132. instance?: Mesh;
  51133. invertUV?: boolean;
  51134. }, scene?: Nullable<Scene>): Mesh;
  51135. /**
  51136. * Creates an custom extruded shape mesh.
  51137. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51138. * * 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.
  51139. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51140. * * 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
  51141. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51142. * * 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
  51143. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51144. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51145. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51146. * * 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
  51147. * * 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
  51148. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51150. * * 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
  51151. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51153. * @param name defines the name of the mesh
  51154. * @param options defines the options used to create the mesh
  51155. * @param scene defines the hosting scene
  51156. * @returns the custom extruded shape mesh
  51157. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51158. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51159. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51160. */
  51161. static ExtrudeShapeCustom(name: string, options: {
  51162. shape: Vector3[];
  51163. path: Vector3[];
  51164. scaleFunction?: any;
  51165. rotationFunction?: any;
  51166. ribbonCloseArray?: boolean;
  51167. ribbonClosePath?: boolean;
  51168. cap?: number;
  51169. updatable?: boolean;
  51170. sideOrientation?: number;
  51171. frontUVs?: Vector4;
  51172. backUVs?: Vector4;
  51173. instance?: Mesh;
  51174. invertUV?: boolean;
  51175. }, scene?: Nullable<Scene>): Mesh;
  51176. private static _ExtrudeShapeGeneric;
  51177. }
  51178. }
  51179. declare module BABYLON {
  51180. /**
  51181. * AmmoJS Physics plugin
  51182. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51183. * @see https://github.com/kripken/ammo.js/
  51184. */
  51185. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51186. private _useDeltaForWorldStep;
  51187. /**
  51188. * Reference to the Ammo library
  51189. */
  51190. bjsAMMO: any;
  51191. /**
  51192. * Created ammoJS world which physics bodies are added to
  51193. */
  51194. world: any;
  51195. /**
  51196. * Name of the plugin
  51197. */
  51198. name: string;
  51199. private _timeStep;
  51200. private _fixedTimeStep;
  51201. private _maxSteps;
  51202. private _tmpQuaternion;
  51203. private _tmpAmmoTransform;
  51204. private _tmpAmmoQuaternion;
  51205. private _tmpAmmoConcreteContactResultCallback;
  51206. private _collisionConfiguration;
  51207. private _dispatcher;
  51208. private _overlappingPairCache;
  51209. private _solver;
  51210. private _softBodySolver;
  51211. private _tmpAmmoVectorA;
  51212. private _tmpAmmoVectorB;
  51213. private _tmpAmmoVectorC;
  51214. private _tmpAmmoVectorD;
  51215. private _tmpContactCallbackResult;
  51216. private _tmpAmmoVectorRCA;
  51217. private _tmpAmmoVectorRCB;
  51218. private _raycastResult;
  51219. private static readonly DISABLE_COLLISION_FLAG;
  51220. private static readonly KINEMATIC_FLAG;
  51221. private static readonly DISABLE_DEACTIVATION_FLAG;
  51222. /**
  51223. * Initializes the ammoJS plugin
  51224. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51225. * @param ammoInjection can be used to inject your own ammo reference
  51226. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51227. */
  51228. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51229. /**
  51230. * Sets the gravity of the physics world (m/(s^2))
  51231. * @param gravity Gravity to set
  51232. */
  51233. setGravity(gravity: Vector3): void;
  51234. /**
  51235. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51236. * @param timeStep timestep to use in seconds
  51237. */
  51238. setTimeStep(timeStep: number): void;
  51239. /**
  51240. * 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)
  51241. * @param fixedTimeStep fixedTimeStep to use in seconds
  51242. */
  51243. setFixedTimeStep(fixedTimeStep: number): void;
  51244. /**
  51245. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51246. * @param maxSteps the maximum number of steps by the physics engine per frame
  51247. */
  51248. setMaxSteps(maxSteps: number): void;
  51249. /**
  51250. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51251. * @returns the current timestep in seconds
  51252. */
  51253. getTimeStep(): number;
  51254. private _isImpostorInContact;
  51255. private _isImpostorPairInContact;
  51256. private _stepSimulation;
  51257. /**
  51258. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51259. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51260. * After the step the babylon meshes are set to the position of the physics imposters
  51261. * @param delta amount of time to step forward
  51262. * @param impostors array of imposters to update before/after the step
  51263. */
  51264. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51265. /**
  51266. * Update babylon mesh to match physics world object
  51267. * @param impostor imposter to match
  51268. */
  51269. private _afterSoftStep;
  51270. /**
  51271. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51272. * @param impostor imposter to match
  51273. */
  51274. private _ropeStep;
  51275. /**
  51276. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51277. * @param impostor imposter to match
  51278. */
  51279. private _softbodyOrClothStep;
  51280. private _tmpVector;
  51281. private _tmpMatrix;
  51282. /**
  51283. * Applies an impulse on the imposter
  51284. * @param impostor imposter to apply impulse to
  51285. * @param force amount of force to be applied to the imposter
  51286. * @param contactPoint the location to apply the impulse on the imposter
  51287. */
  51288. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51289. /**
  51290. * Applies a force on the imposter
  51291. * @param impostor imposter to apply force
  51292. * @param force amount of force to be applied to the imposter
  51293. * @param contactPoint the location to apply the force on the imposter
  51294. */
  51295. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51296. /**
  51297. * Creates a physics body using the plugin
  51298. * @param impostor the imposter to create the physics body on
  51299. */
  51300. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51301. /**
  51302. * Removes the physics body from the imposter and disposes of the body's memory
  51303. * @param impostor imposter to remove the physics body from
  51304. */
  51305. removePhysicsBody(impostor: PhysicsImpostor): void;
  51306. /**
  51307. * Generates a joint
  51308. * @param impostorJoint the imposter joint to create the joint with
  51309. */
  51310. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51311. /**
  51312. * Removes a joint
  51313. * @param impostorJoint the imposter joint to remove the joint from
  51314. */
  51315. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51316. private _addMeshVerts;
  51317. /**
  51318. * Initialise the soft body vertices to match its object's (mesh) vertices
  51319. * Softbody vertices (nodes) are in world space and to match this
  51320. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51321. * @param impostor to create the softbody for
  51322. */
  51323. private _softVertexData;
  51324. /**
  51325. * Create an impostor's soft body
  51326. * @param impostor to create the softbody for
  51327. */
  51328. private _createSoftbody;
  51329. /**
  51330. * Create cloth for an impostor
  51331. * @param impostor to create the softbody for
  51332. */
  51333. private _createCloth;
  51334. /**
  51335. * Create rope for an impostor
  51336. * @param impostor to create the softbody for
  51337. */
  51338. private _createRope;
  51339. private _addHullVerts;
  51340. private _createShape;
  51341. /**
  51342. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51343. * @param impostor imposter containing the physics body and babylon object
  51344. */
  51345. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51346. /**
  51347. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51348. * @param impostor imposter containing the physics body and babylon object
  51349. * @param newPosition new position
  51350. * @param newRotation new rotation
  51351. */
  51352. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51353. /**
  51354. * If this plugin is supported
  51355. * @returns true if its supported
  51356. */
  51357. isSupported(): boolean;
  51358. /**
  51359. * Sets the linear velocity of the physics body
  51360. * @param impostor imposter to set the velocity on
  51361. * @param velocity velocity to set
  51362. */
  51363. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51364. /**
  51365. * Sets the angular velocity of the physics body
  51366. * @param impostor imposter to set the velocity on
  51367. * @param velocity velocity to set
  51368. */
  51369. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51370. /**
  51371. * gets the linear velocity
  51372. * @param impostor imposter to get linear velocity from
  51373. * @returns linear velocity
  51374. */
  51375. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51376. /**
  51377. * gets the angular velocity
  51378. * @param impostor imposter to get angular velocity from
  51379. * @returns angular velocity
  51380. */
  51381. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51382. /**
  51383. * Sets the mass of physics body
  51384. * @param impostor imposter to set the mass on
  51385. * @param mass mass to set
  51386. */
  51387. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51388. /**
  51389. * Gets the mass of the physics body
  51390. * @param impostor imposter to get the mass from
  51391. * @returns mass
  51392. */
  51393. getBodyMass(impostor: PhysicsImpostor): number;
  51394. /**
  51395. * Gets friction of the impostor
  51396. * @param impostor impostor to get friction from
  51397. * @returns friction value
  51398. */
  51399. getBodyFriction(impostor: PhysicsImpostor): number;
  51400. /**
  51401. * Sets friction of the impostor
  51402. * @param impostor impostor to set friction on
  51403. * @param friction friction value
  51404. */
  51405. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51406. /**
  51407. * Gets restitution of the impostor
  51408. * @param impostor impostor to get restitution from
  51409. * @returns restitution value
  51410. */
  51411. getBodyRestitution(impostor: PhysicsImpostor): number;
  51412. /**
  51413. * Sets resitution of the impostor
  51414. * @param impostor impostor to set resitution on
  51415. * @param restitution resitution value
  51416. */
  51417. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51418. /**
  51419. * Gets pressure inside the impostor
  51420. * @param impostor impostor to get pressure from
  51421. * @returns pressure value
  51422. */
  51423. getBodyPressure(impostor: PhysicsImpostor): number;
  51424. /**
  51425. * Sets pressure inside a soft body impostor
  51426. * Cloth and rope must remain 0 pressure
  51427. * @param impostor impostor to set pressure on
  51428. * @param pressure pressure value
  51429. */
  51430. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51431. /**
  51432. * Gets stiffness of the impostor
  51433. * @param impostor impostor to get stiffness from
  51434. * @returns pressure value
  51435. */
  51436. getBodyStiffness(impostor: PhysicsImpostor): number;
  51437. /**
  51438. * Sets stiffness of the impostor
  51439. * @param impostor impostor to set stiffness on
  51440. * @param stiffness stiffness value from 0 to 1
  51441. */
  51442. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51443. /**
  51444. * Gets velocityIterations of the impostor
  51445. * @param impostor impostor to get velocity iterations from
  51446. * @returns velocityIterations value
  51447. */
  51448. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51449. /**
  51450. * Sets velocityIterations of the impostor
  51451. * @param impostor impostor to set velocity iterations on
  51452. * @param velocityIterations velocityIterations value
  51453. */
  51454. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51455. /**
  51456. * Gets positionIterations of the impostor
  51457. * @param impostor impostor to get position iterations from
  51458. * @returns positionIterations value
  51459. */
  51460. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51461. /**
  51462. * Sets positionIterations of the impostor
  51463. * @param impostor impostor to set position on
  51464. * @param positionIterations positionIterations value
  51465. */
  51466. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51467. /**
  51468. * Append an anchor to a cloth object
  51469. * @param impostor is the cloth impostor to add anchor to
  51470. * @param otherImpostor is the rigid impostor to anchor to
  51471. * @param width ratio across width from 0 to 1
  51472. * @param height ratio up height from 0 to 1
  51473. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51474. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51475. */
  51476. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51477. /**
  51478. * Append an hook to a rope object
  51479. * @param impostor is the rope impostor to add hook to
  51480. * @param otherImpostor is the rigid impostor to hook to
  51481. * @param length ratio along the rope from 0 to 1
  51482. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51483. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51484. */
  51485. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51486. /**
  51487. * Sleeps the physics body and stops it from being active
  51488. * @param impostor impostor to sleep
  51489. */
  51490. sleepBody(impostor: PhysicsImpostor): void;
  51491. /**
  51492. * Activates the physics body
  51493. * @param impostor impostor to activate
  51494. */
  51495. wakeUpBody(impostor: PhysicsImpostor): void;
  51496. /**
  51497. * Updates the distance parameters of the joint
  51498. * @param joint joint to update
  51499. * @param maxDistance maximum distance of the joint
  51500. * @param minDistance minimum distance of the joint
  51501. */
  51502. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51503. /**
  51504. * Sets a motor on the joint
  51505. * @param joint joint to set motor on
  51506. * @param speed speed of the motor
  51507. * @param maxForce maximum force of the motor
  51508. * @param motorIndex index of the motor
  51509. */
  51510. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51511. /**
  51512. * Sets the motors limit
  51513. * @param joint joint to set limit on
  51514. * @param upperLimit upper limit
  51515. * @param lowerLimit lower limit
  51516. */
  51517. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51518. /**
  51519. * Syncs the position and rotation of a mesh with the impostor
  51520. * @param mesh mesh to sync
  51521. * @param impostor impostor to update the mesh with
  51522. */
  51523. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51524. /**
  51525. * Gets the radius of the impostor
  51526. * @param impostor impostor to get radius from
  51527. * @returns the radius
  51528. */
  51529. getRadius(impostor: PhysicsImpostor): number;
  51530. /**
  51531. * Gets the box size of the impostor
  51532. * @param impostor impostor to get box size from
  51533. * @param result the resulting box size
  51534. */
  51535. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51536. /**
  51537. * Disposes of the impostor
  51538. */
  51539. dispose(): void;
  51540. /**
  51541. * Does a raycast in the physics world
  51542. * @param from when should the ray start?
  51543. * @param to when should the ray end?
  51544. * @returns PhysicsRaycastResult
  51545. */
  51546. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51547. }
  51548. }
  51549. declare module BABYLON {
  51550. interface AbstractScene {
  51551. /**
  51552. * The list of reflection probes added to the scene
  51553. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51554. */
  51555. reflectionProbes: Array<ReflectionProbe>;
  51556. /**
  51557. * Removes the given reflection probe from this scene.
  51558. * @param toRemove The reflection probe to remove
  51559. * @returns The index of the removed reflection probe
  51560. */
  51561. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51562. /**
  51563. * Adds the given reflection probe to this scene.
  51564. * @param newReflectionProbe The reflection probe to add
  51565. */
  51566. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51567. }
  51568. /**
  51569. * Class used to generate realtime reflection / refraction cube textures
  51570. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51571. */
  51572. export class ReflectionProbe {
  51573. /** defines the name of the probe */
  51574. name: string;
  51575. private _scene;
  51576. private _renderTargetTexture;
  51577. private _projectionMatrix;
  51578. private _viewMatrix;
  51579. private _target;
  51580. private _add;
  51581. private _attachedMesh;
  51582. private _invertYAxis;
  51583. /** Gets or sets probe position (center of the cube map) */
  51584. position: Vector3;
  51585. /**
  51586. * Creates a new reflection probe
  51587. * @param name defines the name of the probe
  51588. * @param size defines the texture resolution (for each face)
  51589. * @param scene defines the hosting scene
  51590. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51591. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51592. */
  51593. constructor(
  51594. /** defines the name of the probe */
  51595. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51596. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51597. samples: number;
  51598. /** Gets or sets the refresh rate to use (on every frame by default) */
  51599. refreshRate: number;
  51600. /**
  51601. * Gets the hosting scene
  51602. * @returns a Scene
  51603. */
  51604. getScene(): Scene;
  51605. /** Gets the internal CubeTexture used to render to */
  51606. readonly cubeTexture: RenderTargetTexture;
  51607. /** Gets the list of meshes to render */
  51608. readonly renderList: Nullable<AbstractMesh[]>;
  51609. /**
  51610. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51611. * @param mesh defines the mesh to attach to
  51612. */
  51613. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51614. /**
  51615. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51616. * @param renderingGroupId The rendering group id corresponding to its index
  51617. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51618. */
  51619. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51620. /**
  51621. * Clean all associated resources
  51622. */
  51623. dispose(): void;
  51624. /**
  51625. * Converts the reflection probe information to a readable string for debug purpose.
  51626. * @param fullDetails Supports for multiple levels of logging within scene loading
  51627. * @returns the human readable reflection probe info
  51628. */
  51629. toString(fullDetails?: boolean): string;
  51630. /**
  51631. * Get the class name of the relfection probe.
  51632. * @returns "ReflectionProbe"
  51633. */
  51634. getClassName(): string;
  51635. /**
  51636. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51637. * @returns The JSON representation of the texture
  51638. */
  51639. serialize(): any;
  51640. /**
  51641. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51642. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51643. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51644. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51645. * @returns The parsed reflection probe if successful
  51646. */
  51647. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51648. }
  51649. }
  51650. declare module BABYLON {
  51651. /** @hidden */
  51652. export var _BabylonLoaderRegistered: boolean;
  51653. }
  51654. declare module BABYLON {
  51655. /**
  51656. * The Physically based simple base material of BJS.
  51657. *
  51658. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51659. * It is used as the base class for both the specGloss and metalRough conventions.
  51660. */
  51661. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51662. /**
  51663. * Number of Simultaneous lights allowed on the material.
  51664. */
  51665. maxSimultaneousLights: number;
  51666. /**
  51667. * If sets to true, disables all the lights affecting the material.
  51668. */
  51669. disableLighting: boolean;
  51670. /**
  51671. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51672. */
  51673. environmentTexture: BaseTexture;
  51674. /**
  51675. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51676. */
  51677. invertNormalMapX: boolean;
  51678. /**
  51679. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51680. */
  51681. invertNormalMapY: boolean;
  51682. /**
  51683. * Normal map used in the model.
  51684. */
  51685. normalTexture: BaseTexture;
  51686. /**
  51687. * Emissivie color used to self-illuminate the model.
  51688. */
  51689. emissiveColor: Color3;
  51690. /**
  51691. * Emissivie texture used to self-illuminate the model.
  51692. */
  51693. emissiveTexture: BaseTexture;
  51694. /**
  51695. * Occlusion Channel Strenght.
  51696. */
  51697. occlusionStrength: number;
  51698. /**
  51699. * Occlusion Texture of the material (adding extra occlusion effects).
  51700. */
  51701. occlusionTexture: BaseTexture;
  51702. /**
  51703. * Defines the alpha limits in alpha test mode.
  51704. */
  51705. alphaCutOff: number;
  51706. /**
  51707. * Gets the current double sided mode.
  51708. */
  51709. /**
  51710. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51711. */
  51712. doubleSided: boolean;
  51713. /**
  51714. * Stores the pre-calculated light information of a mesh in a texture.
  51715. */
  51716. lightmapTexture: BaseTexture;
  51717. /**
  51718. * If true, the light map contains occlusion information instead of lighting info.
  51719. */
  51720. useLightmapAsShadowmap: boolean;
  51721. /**
  51722. * Instantiates a new PBRMaterial instance.
  51723. *
  51724. * @param name The material name
  51725. * @param scene The scene the material will be use in.
  51726. */
  51727. constructor(name: string, scene: Scene);
  51728. getClassName(): string;
  51729. }
  51730. }
  51731. declare module BABYLON {
  51732. /**
  51733. * The PBR material of BJS following the metal roughness convention.
  51734. *
  51735. * This fits to the PBR convention in the GLTF definition:
  51736. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51737. */
  51738. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51739. /**
  51740. * The base color has two different interpretations depending on the value of metalness.
  51741. * When the material is a metal, the base color is the specific measured reflectance value
  51742. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51743. * of the material.
  51744. */
  51745. baseColor: Color3;
  51746. /**
  51747. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51748. * well as opacity information in the alpha channel.
  51749. */
  51750. baseTexture: BaseTexture;
  51751. /**
  51752. * Specifies the metallic scalar value of the material.
  51753. * Can also be used to scale the metalness values of the metallic texture.
  51754. */
  51755. metallic: number;
  51756. /**
  51757. * Specifies the roughness scalar value of the material.
  51758. * Can also be used to scale the roughness values of the metallic texture.
  51759. */
  51760. roughness: number;
  51761. /**
  51762. * Texture containing both the metallic value in the B channel and the
  51763. * roughness value in the G channel to keep better precision.
  51764. */
  51765. metallicRoughnessTexture: BaseTexture;
  51766. /**
  51767. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51768. *
  51769. * @param name The material name
  51770. * @param scene The scene the material will be use in.
  51771. */
  51772. constructor(name: string, scene: Scene);
  51773. /**
  51774. * Return the currrent class name of the material.
  51775. */
  51776. getClassName(): string;
  51777. /**
  51778. * Makes a duplicate of the current material.
  51779. * @param name - name to use for the new material.
  51780. */
  51781. clone(name: string): PBRMetallicRoughnessMaterial;
  51782. /**
  51783. * Serialize the material to a parsable JSON object.
  51784. */
  51785. serialize(): any;
  51786. /**
  51787. * Parses a JSON object correponding to the serialize function.
  51788. */
  51789. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51790. }
  51791. }
  51792. declare module BABYLON {
  51793. /**
  51794. * The PBR material of BJS following the specular glossiness convention.
  51795. *
  51796. * This fits to the PBR convention in the GLTF definition:
  51797. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51798. */
  51799. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51800. /**
  51801. * Specifies the diffuse color of the material.
  51802. */
  51803. diffuseColor: Color3;
  51804. /**
  51805. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51806. * channel.
  51807. */
  51808. diffuseTexture: BaseTexture;
  51809. /**
  51810. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51811. */
  51812. specularColor: Color3;
  51813. /**
  51814. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51815. */
  51816. glossiness: number;
  51817. /**
  51818. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51819. */
  51820. specularGlossinessTexture: BaseTexture;
  51821. /**
  51822. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51823. *
  51824. * @param name The material name
  51825. * @param scene The scene the material will be use in.
  51826. */
  51827. constructor(name: string, scene: Scene);
  51828. /**
  51829. * Return the currrent class name of the material.
  51830. */
  51831. getClassName(): string;
  51832. /**
  51833. * Makes a duplicate of the current material.
  51834. * @param name - name to use for the new material.
  51835. */
  51836. clone(name: string): PBRSpecularGlossinessMaterial;
  51837. /**
  51838. * Serialize the material to a parsable JSON object.
  51839. */
  51840. serialize(): any;
  51841. /**
  51842. * Parses a JSON object correponding to the serialize function.
  51843. */
  51844. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51845. }
  51846. }
  51847. declare module BABYLON {
  51848. /**
  51849. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51850. * It can help converting any input color in a desired output one. This can then be used to create effects
  51851. * from sepia, black and white to sixties or futuristic rendering...
  51852. *
  51853. * The only supported format is currently 3dl.
  51854. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51855. */
  51856. export class ColorGradingTexture extends BaseTexture {
  51857. /**
  51858. * The current texture matrix. (will always be identity in color grading texture)
  51859. */
  51860. private _textureMatrix;
  51861. /**
  51862. * The texture URL.
  51863. */
  51864. url: string;
  51865. /**
  51866. * Empty line regex stored for GC.
  51867. */
  51868. private static _noneEmptyLineRegex;
  51869. private _engine;
  51870. /**
  51871. * Instantiates a ColorGradingTexture from the following parameters.
  51872. *
  51873. * @param url The location of the color gradind data (currently only supporting 3dl)
  51874. * @param scene The scene the texture will be used in
  51875. */
  51876. constructor(url: string, scene: Scene);
  51877. /**
  51878. * Returns the texture matrix used in most of the material.
  51879. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51880. */
  51881. getTextureMatrix(): Matrix;
  51882. /**
  51883. * Occurs when the file being loaded is a .3dl LUT file.
  51884. */
  51885. private load3dlTexture;
  51886. /**
  51887. * Starts the loading process of the texture.
  51888. */
  51889. private loadTexture;
  51890. /**
  51891. * Clones the color gradind texture.
  51892. */
  51893. clone(): ColorGradingTexture;
  51894. /**
  51895. * Called during delayed load for textures.
  51896. */
  51897. delayLoad(): void;
  51898. /**
  51899. * Parses a color grading texture serialized by Babylon.
  51900. * @param parsedTexture The texture information being parsedTexture
  51901. * @param scene The scene to load the texture in
  51902. * @param rootUrl The root url of the data assets to load
  51903. * @return A color gradind texture
  51904. */
  51905. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51906. /**
  51907. * Serializes the LUT texture to json format.
  51908. */
  51909. serialize(): any;
  51910. }
  51911. }
  51912. declare module BABYLON {
  51913. /**
  51914. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51915. */
  51916. export class EquiRectangularCubeTexture extends BaseTexture {
  51917. /** The six faces of the cube. */
  51918. private static _FacesMapping;
  51919. private _noMipmap;
  51920. private _onLoad;
  51921. private _onError;
  51922. /** The size of the cubemap. */
  51923. private _size;
  51924. /** The buffer of the image. */
  51925. private _buffer;
  51926. /** The width of the input image. */
  51927. private _width;
  51928. /** The height of the input image. */
  51929. private _height;
  51930. /** The URL to the image. */
  51931. url: string;
  51932. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51933. coordinatesMode: number;
  51934. /**
  51935. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51936. * @param url The location of the image
  51937. * @param scene The scene the texture will be used in
  51938. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51939. * @param noMipmap Forces to not generate the mipmap if true
  51940. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51941. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51942. * @param onLoad — defines a callback called when texture is loaded
  51943. * @param onError — defines a callback called if there is an error
  51944. */
  51945. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51946. /**
  51947. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51948. */
  51949. private loadImage;
  51950. /**
  51951. * Convert the image buffer into a cubemap and create a CubeTexture.
  51952. */
  51953. private loadTexture;
  51954. /**
  51955. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51956. * @param buffer The ArrayBuffer that should be converted.
  51957. * @returns The buffer as Float32Array.
  51958. */
  51959. private getFloat32ArrayFromArrayBuffer;
  51960. /**
  51961. * Get the current class name of the texture useful for serialization or dynamic coding.
  51962. * @returns "EquiRectangularCubeTexture"
  51963. */
  51964. getClassName(): string;
  51965. /**
  51966. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51967. * @returns A clone of the current EquiRectangularCubeTexture.
  51968. */
  51969. clone(): EquiRectangularCubeTexture;
  51970. }
  51971. }
  51972. declare module BABYLON {
  51973. /**
  51974. * Based on jsTGALoader - Javascript loader for TGA file
  51975. * By Vincent Thibault
  51976. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51977. */
  51978. export class TGATools {
  51979. private static _TYPE_INDEXED;
  51980. private static _TYPE_RGB;
  51981. private static _TYPE_GREY;
  51982. private static _TYPE_RLE_INDEXED;
  51983. private static _TYPE_RLE_RGB;
  51984. private static _TYPE_RLE_GREY;
  51985. private static _ORIGIN_MASK;
  51986. private static _ORIGIN_SHIFT;
  51987. private static _ORIGIN_BL;
  51988. private static _ORIGIN_BR;
  51989. private static _ORIGIN_UL;
  51990. private static _ORIGIN_UR;
  51991. /**
  51992. * Gets the header of a TGA file
  51993. * @param data defines the TGA data
  51994. * @returns the header
  51995. */
  51996. static GetTGAHeader(data: Uint8Array): any;
  51997. /**
  51998. * Uploads TGA content to a Babylon Texture
  51999. * @hidden
  52000. */
  52001. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52002. /** @hidden */
  52003. 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;
  52004. /** @hidden */
  52005. 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;
  52006. /** @hidden */
  52007. 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;
  52008. /** @hidden */
  52009. 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;
  52010. /** @hidden */
  52011. 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;
  52012. /** @hidden */
  52013. 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;
  52014. }
  52015. }
  52016. declare module BABYLON {
  52017. /**
  52018. * Implementation of the TGA Texture Loader.
  52019. * @hidden
  52020. */
  52021. export class _TGATextureLoader implements IInternalTextureLoader {
  52022. /**
  52023. * Defines wether the loader supports cascade loading the different faces.
  52024. */
  52025. readonly supportCascades: boolean;
  52026. /**
  52027. * This returns if the loader support the current file information.
  52028. * @param extension defines the file extension of the file being loaded
  52029. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52030. * @param fallback defines the fallback internal texture if any
  52031. * @param isBase64 defines whether the texture is encoded as a base64
  52032. * @param isBuffer defines whether the texture data are stored as a buffer
  52033. * @returns true if the loader can load the specified file
  52034. */
  52035. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52036. /**
  52037. * Transform the url before loading if required.
  52038. * @param rootUrl the url of the texture
  52039. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52040. * @returns the transformed texture
  52041. */
  52042. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52043. /**
  52044. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52045. * @param rootUrl the url of the texture
  52046. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52047. * @returns the fallback texture
  52048. */
  52049. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52050. /**
  52051. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52052. * @param data contains the texture data
  52053. * @param texture defines the BabylonJS internal texture
  52054. * @param createPolynomials will be true if polynomials have been requested
  52055. * @param onLoad defines the callback to trigger once the texture is ready
  52056. * @param onError defines the callback to trigger in case of error
  52057. */
  52058. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52059. /**
  52060. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52061. * @param data contains the texture data
  52062. * @param texture defines the BabylonJS internal texture
  52063. * @param callback defines the method to call once ready to upload
  52064. */
  52065. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52066. }
  52067. }
  52068. declare module BABYLON {
  52069. /**
  52070. * Info about the .basis files
  52071. */
  52072. class BasisFileInfo {
  52073. /**
  52074. * If the file has alpha
  52075. */
  52076. hasAlpha: boolean;
  52077. /**
  52078. * Info about each image of the basis file
  52079. */
  52080. images: Array<{
  52081. levels: Array<{
  52082. width: number;
  52083. height: number;
  52084. transcodedPixels: ArrayBufferView;
  52085. }>;
  52086. }>;
  52087. }
  52088. /**
  52089. * Result of transcoding a basis file
  52090. */
  52091. class TranscodeResult {
  52092. /**
  52093. * Info about the .basis file
  52094. */
  52095. fileInfo: BasisFileInfo;
  52096. /**
  52097. * Format to use when loading the file
  52098. */
  52099. format: number;
  52100. }
  52101. /**
  52102. * Configuration options for the Basis transcoder
  52103. */
  52104. export class BasisTranscodeConfiguration {
  52105. /**
  52106. * Supported compression formats used to determine the supported output format of the transcoder
  52107. */
  52108. supportedCompressionFormats?: {
  52109. /**
  52110. * etc1 compression format
  52111. */
  52112. etc1?: boolean;
  52113. /**
  52114. * s3tc compression format
  52115. */
  52116. s3tc?: boolean;
  52117. /**
  52118. * pvrtc compression format
  52119. */
  52120. pvrtc?: boolean;
  52121. /**
  52122. * etc2 compression format
  52123. */
  52124. etc2?: boolean;
  52125. };
  52126. /**
  52127. * If mipmap levels should be loaded for transcoded images (Default: true)
  52128. */
  52129. loadMipmapLevels?: boolean;
  52130. /**
  52131. * Index of a single image to load (Default: all images)
  52132. */
  52133. loadSingleImage?: number;
  52134. }
  52135. /**
  52136. * Used to load .Basis files
  52137. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52138. */
  52139. export class BasisTools {
  52140. private static _IgnoreSupportedFormats;
  52141. /**
  52142. * URL to use when loading the basis transcoder
  52143. */
  52144. static JSModuleURL: string;
  52145. /**
  52146. * URL to use when loading the wasm module for the transcoder
  52147. */
  52148. static WasmModuleURL: string;
  52149. /**
  52150. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52151. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52152. * @returns internal format corresponding to the Basis format
  52153. */
  52154. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52155. private static _WorkerPromise;
  52156. private static _Worker;
  52157. private static _actionId;
  52158. private static _CreateWorkerAsync;
  52159. /**
  52160. * Transcodes a loaded image file to compressed pixel data
  52161. * @param imageData image data to transcode
  52162. * @param config configuration options for the transcoding
  52163. * @returns a promise resulting in the transcoded image
  52164. */
  52165. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52166. /**
  52167. * Loads a texture from the transcode result
  52168. * @param texture texture load to
  52169. * @param transcodeResult the result of transcoding the basis file to load from
  52170. */
  52171. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52172. }
  52173. }
  52174. declare module BABYLON {
  52175. /**
  52176. * Loader for .basis file format
  52177. */
  52178. export class _BasisTextureLoader implements IInternalTextureLoader {
  52179. /**
  52180. * Defines whether the loader supports cascade loading the different faces.
  52181. */
  52182. readonly supportCascades: boolean;
  52183. /**
  52184. * This returns if the loader support the current file information.
  52185. * @param extension defines the file extension of the file being loaded
  52186. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52187. * @param fallback defines the fallback internal texture if any
  52188. * @param isBase64 defines whether the texture is encoded as a base64
  52189. * @param isBuffer defines whether the texture data are stored as a buffer
  52190. * @returns true if the loader can load the specified file
  52191. */
  52192. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52193. /**
  52194. * Transform the url before loading if required.
  52195. * @param rootUrl the url of the texture
  52196. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52197. * @returns the transformed texture
  52198. */
  52199. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52200. /**
  52201. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52202. * @param rootUrl the url of the texture
  52203. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52204. * @returns the fallback texture
  52205. */
  52206. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52207. /**
  52208. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52209. * @param data contains the texture data
  52210. * @param texture defines the BabylonJS internal texture
  52211. * @param createPolynomials will be true if polynomials have been requested
  52212. * @param onLoad defines the callback to trigger once the texture is ready
  52213. * @param onError defines the callback to trigger in case of error
  52214. */
  52215. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52216. /**
  52217. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52218. * @param data contains the texture data
  52219. * @param texture defines the BabylonJS internal texture
  52220. * @param callback defines the method to call once ready to upload
  52221. */
  52222. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52223. }
  52224. }
  52225. declare module BABYLON {
  52226. /**
  52227. * 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.
  52228. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52229. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52230. */
  52231. export class CustomProceduralTexture extends ProceduralTexture {
  52232. private _animate;
  52233. private _time;
  52234. private _config;
  52235. private _texturePath;
  52236. /**
  52237. * Instantiates a new Custom Procedural Texture.
  52238. * 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.
  52239. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52240. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52241. * @param name Define the name of the texture
  52242. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52243. * @param size Define the size of the texture to create
  52244. * @param scene Define the scene the texture belongs to
  52245. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52246. * @param generateMipMaps Define if the texture should creates mip maps or not
  52247. */
  52248. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52249. private _loadJson;
  52250. /**
  52251. * Is the texture ready to be used ? (rendered at least once)
  52252. * @returns true if ready, otherwise, false.
  52253. */
  52254. isReady(): boolean;
  52255. /**
  52256. * Render the texture to its associated render target.
  52257. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52258. */
  52259. render(useCameraPostProcess?: boolean): void;
  52260. /**
  52261. * Update the list of dependant textures samplers in the shader.
  52262. */
  52263. updateTextures(): void;
  52264. /**
  52265. * Update the uniform values of the procedural texture in the shader.
  52266. */
  52267. updateShaderUniforms(): void;
  52268. /**
  52269. * Define if the texture animates or not.
  52270. */
  52271. animate: boolean;
  52272. }
  52273. }
  52274. declare module BABYLON {
  52275. /** @hidden */
  52276. export var noisePixelShader: {
  52277. name: string;
  52278. shader: string;
  52279. };
  52280. }
  52281. declare module BABYLON {
  52282. /**
  52283. * Class used to generate noise procedural textures
  52284. */
  52285. export class NoiseProceduralTexture extends ProceduralTexture {
  52286. private _time;
  52287. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52288. brightness: number;
  52289. /** Defines the number of octaves to process */
  52290. octaves: number;
  52291. /** Defines the level of persistence (0.8 by default) */
  52292. persistence: number;
  52293. /** Gets or sets animation speed factor (default is 1) */
  52294. animationSpeedFactor: number;
  52295. /**
  52296. * Creates a new NoiseProceduralTexture
  52297. * @param name defines the name fo the texture
  52298. * @param size defines the size of the texture (default is 256)
  52299. * @param scene defines the hosting scene
  52300. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52301. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52302. */
  52303. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52304. private _updateShaderUniforms;
  52305. protected _getDefines(): string;
  52306. /** Generate the current state of the procedural texture */
  52307. render(useCameraPostProcess?: boolean): void;
  52308. /**
  52309. * Serializes this noise procedural texture
  52310. * @returns a serialized noise procedural texture object
  52311. */
  52312. serialize(): any;
  52313. /**
  52314. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52315. * @param parsedTexture defines parsed texture data
  52316. * @param scene defines the current scene
  52317. * @param rootUrl defines the root URL containing noise procedural texture information
  52318. * @returns a parsed NoiseProceduralTexture
  52319. */
  52320. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52321. }
  52322. }
  52323. declare module BABYLON {
  52324. /**
  52325. * Raw cube texture where the raw buffers are passed in
  52326. */
  52327. export class RawCubeTexture extends CubeTexture {
  52328. /**
  52329. * Creates a cube texture where the raw buffers are passed in.
  52330. * @param scene defines the scene the texture is attached to
  52331. * @param data defines the array of data to use to create each face
  52332. * @param size defines the size of the textures
  52333. * @param format defines the format of the data
  52334. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52335. * @param generateMipMaps defines if the engine should generate the mip levels
  52336. * @param invertY defines if data must be stored with Y axis inverted
  52337. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52338. * @param compression defines the compression used (null by default)
  52339. */
  52340. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52341. /**
  52342. * Updates the raw cube texture.
  52343. * @param data defines the data to store
  52344. * @param format defines the data format
  52345. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52346. * @param invertY defines if data must be stored with Y axis inverted
  52347. * @param compression defines the compression used (null by default)
  52348. * @param level defines which level of the texture to update
  52349. */
  52350. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52351. /**
  52352. * Updates a raw cube texture with RGBD encoded data.
  52353. * @param data defines the array of data [mipmap][face] to use to create each face
  52354. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52355. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52356. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52357. * @returns a promsie that resolves when the operation is complete
  52358. */
  52359. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52360. /**
  52361. * Clones the raw cube texture.
  52362. * @return a new cube texture
  52363. */
  52364. clone(): CubeTexture;
  52365. /** @hidden */
  52366. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52367. }
  52368. }
  52369. declare module BABYLON {
  52370. /**
  52371. * Class used to store 3D textures containing user data
  52372. */
  52373. export class RawTexture3D extends Texture {
  52374. /** Gets or sets the texture format to use */
  52375. format: number;
  52376. private _engine;
  52377. /**
  52378. * Create a new RawTexture3D
  52379. * @param data defines the data of the texture
  52380. * @param width defines the width of the texture
  52381. * @param height defines the height of the texture
  52382. * @param depth defines the depth of the texture
  52383. * @param format defines the texture format to use
  52384. * @param scene defines the hosting scene
  52385. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52386. * @param invertY defines if texture must be stored with Y axis inverted
  52387. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52388. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52389. */
  52390. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52391. /** Gets or sets the texture format to use */
  52392. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52393. /**
  52394. * Update the texture with new data
  52395. * @param data defines the data to store in the texture
  52396. */
  52397. update(data: ArrayBufferView): void;
  52398. }
  52399. }
  52400. declare module BABYLON {
  52401. /**
  52402. * Creates a refraction texture used by refraction channel of the standard material.
  52403. * It is like a mirror but to see through a material.
  52404. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52405. */
  52406. export class RefractionTexture extends RenderTargetTexture {
  52407. /**
  52408. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52409. * 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.
  52410. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52411. */
  52412. refractionPlane: Plane;
  52413. /**
  52414. * Define how deep under the surface we should see.
  52415. */
  52416. depth: number;
  52417. /**
  52418. * Creates a refraction texture used by refraction channel of the standard material.
  52419. * It is like a mirror but to see through a material.
  52420. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52421. * @param name Define the texture name
  52422. * @param size Define the size of the underlying texture
  52423. * @param scene Define the scene the refraction belongs to
  52424. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52425. */
  52426. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52427. /**
  52428. * Clone the refraction texture.
  52429. * @returns the cloned texture
  52430. */
  52431. clone(): RefractionTexture;
  52432. /**
  52433. * Serialize the texture to a JSON representation you could use in Parse later on
  52434. * @returns the serialized JSON representation
  52435. */
  52436. serialize(): any;
  52437. }
  52438. }
  52439. declare module BABYLON {
  52440. /**
  52441. * Defines the options related to the creation of an HtmlElementTexture
  52442. */
  52443. export interface IHtmlElementTextureOptions {
  52444. /**
  52445. * Defines wether mip maps should be created or not.
  52446. */
  52447. generateMipMaps?: boolean;
  52448. /**
  52449. * Defines the sampling mode of the texture.
  52450. */
  52451. samplingMode?: number;
  52452. /**
  52453. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52454. */
  52455. engine: Nullable<Engine>;
  52456. /**
  52457. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52458. */
  52459. scene: Nullable<Scene>;
  52460. }
  52461. /**
  52462. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52463. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52464. * is automatically managed.
  52465. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52466. * in your application.
  52467. *
  52468. * As the update is not automatic, you need to call them manually.
  52469. */
  52470. export class HtmlElementTexture extends BaseTexture {
  52471. /**
  52472. * The texture URL.
  52473. */
  52474. element: HTMLVideoElement | HTMLCanvasElement;
  52475. private static readonly DefaultOptions;
  52476. private _textureMatrix;
  52477. private _engine;
  52478. private _isVideo;
  52479. private _generateMipMaps;
  52480. private _samplingMode;
  52481. /**
  52482. * Instantiates a HtmlElementTexture from the following parameters.
  52483. *
  52484. * @param name Defines the name of the texture
  52485. * @param element Defines the video or canvas the texture is filled with
  52486. * @param options Defines the other none mandatory texture creation options
  52487. */
  52488. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52489. private _createInternalTexture;
  52490. /**
  52491. * Returns the texture matrix used in most of the material.
  52492. */
  52493. getTextureMatrix(): Matrix;
  52494. /**
  52495. * Updates the content of the texture.
  52496. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52497. */
  52498. update(invertY?: Nullable<boolean>): void;
  52499. }
  52500. }
  52501. declare module BABYLON {
  52502. /**
  52503. * Enum used to define the target of a block
  52504. */
  52505. export enum NodeMaterialBlockTargets {
  52506. /** Vertex shader */
  52507. Vertex = 1,
  52508. /** Fragment shader */
  52509. Fragment = 2,
  52510. /** Neutral */
  52511. Neutral = 4,
  52512. /** Vertex and Fragment */
  52513. VertexAndFragment = 3
  52514. }
  52515. }
  52516. declare module BABYLON {
  52517. /**
  52518. * Defines the kind of connection point for node based material
  52519. */
  52520. export enum NodeMaterialBlockConnectionPointTypes {
  52521. /** Float */
  52522. Float = 1,
  52523. /** Int */
  52524. Int = 2,
  52525. /** Vector2 */
  52526. Vector2 = 4,
  52527. /** Vector3 */
  52528. Vector3 = 8,
  52529. /** Vector4 */
  52530. Vector4 = 16,
  52531. /** Color3 */
  52532. Color3 = 32,
  52533. /** Color4 */
  52534. Color4 = 64,
  52535. /** Matrix */
  52536. Matrix = 128,
  52537. /** Detect type based on connection */
  52538. AutoDetect = 1024,
  52539. /** Output type that will be defined by input type */
  52540. BasedOnInput = 2048
  52541. }
  52542. }
  52543. declare module BABYLON {
  52544. /**
  52545. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52546. */
  52547. export enum NodeMaterialBlockConnectionPointMode {
  52548. /** Value is an uniform */
  52549. Uniform = 0,
  52550. /** Value is a mesh attribute */
  52551. Attribute = 1,
  52552. /** Value is a varying between vertex and fragment shaders */
  52553. Varying = 2,
  52554. /** Mode is undefined */
  52555. Undefined = 3
  52556. }
  52557. }
  52558. declare module BABYLON {
  52559. /**
  52560. * Enum used to define system values e.g. values automatically provided by the system
  52561. */
  52562. export enum NodeMaterialSystemValues {
  52563. /** World */
  52564. World = 1,
  52565. /** View */
  52566. View = 2,
  52567. /** Projection */
  52568. Projection = 3,
  52569. /** ViewProjection */
  52570. ViewProjection = 4,
  52571. /** WorldView */
  52572. WorldView = 5,
  52573. /** WorldViewProjection */
  52574. WorldViewProjection = 6,
  52575. /** CameraPosition */
  52576. CameraPosition = 7,
  52577. /** Fog Color */
  52578. FogColor = 8,
  52579. /** Delta time */
  52580. DeltaTime = 9
  52581. }
  52582. }
  52583. declare module BABYLON {
  52584. /**
  52585. * Root class for all node material optimizers
  52586. */
  52587. export class NodeMaterialOptimizer {
  52588. /**
  52589. * Function used to optimize a NodeMaterial graph
  52590. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52591. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52592. */
  52593. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52594. }
  52595. }
  52596. declare module BABYLON {
  52597. /**
  52598. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52599. */
  52600. export class TransformBlock extends NodeMaterialBlock {
  52601. /**
  52602. * Defines the value to use to complement W value to transform it to a Vector4
  52603. */
  52604. complementW: number;
  52605. /**
  52606. * Defines the value to use to complement z value to transform it to a Vector4
  52607. */
  52608. complementZ: number;
  52609. /**
  52610. * Creates a new TransformBlock
  52611. * @param name defines the block name
  52612. */
  52613. constructor(name: string);
  52614. /**
  52615. * Gets the current class name
  52616. * @returns the class name
  52617. */
  52618. getClassName(): string;
  52619. /**
  52620. * Gets the vector input
  52621. */
  52622. readonly vector: NodeMaterialConnectionPoint;
  52623. /**
  52624. * Gets the output component
  52625. */
  52626. readonly output: NodeMaterialConnectionPoint;
  52627. /**
  52628. * Gets the matrix transform input
  52629. */
  52630. readonly transform: NodeMaterialConnectionPoint;
  52631. protected _buildBlock(state: NodeMaterialBuildState): this;
  52632. serialize(): any;
  52633. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52634. protected _dumpPropertiesCode(): string;
  52635. }
  52636. }
  52637. declare module BABYLON {
  52638. /**
  52639. * Block used to output the vertex position
  52640. */
  52641. export class VertexOutputBlock extends NodeMaterialBlock {
  52642. /**
  52643. * Creates a new VertexOutputBlock
  52644. * @param name defines the block name
  52645. */
  52646. constructor(name: string);
  52647. /**
  52648. * Gets the current class name
  52649. * @returns the class name
  52650. */
  52651. getClassName(): string;
  52652. /**
  52653. * Gets the vector input component
  52654. */
  52655. readonly vector: NodeMaterialConnectionPoint;
  52656. protected _buildBlock(state: NodeMaterialBuildState): this;
  52657. }
  52658. }
  52659. declare module BABYLON {
  52660. /**
  52661. * Block used to output the final color
  52662. */
  52663. export class FragmentOutputBlock extends NodeMaterialBlock {
  52664. /**
  52665. * Create a new FragmentOutputBlock
  52666. * @param name defines the block name
  52667. */
  52668. constructor(name: string);
  52669. /**
  52670. * Gets the current class name
  52671. * @returns the class name
  52672. */
  52673. getClassName(): string;
  52674. /**
  52675. * Gets the rgba input component
  52676. */
  52677. readonly rgba: NodeMaterialConnectionPoint;
  52678. /**
  52679. * Gets the rgb input component
  52680. */
  52681. readonly rgb: NodeMaterialConnectionPoint;
  52682. /**
  52683. * Gets the a input component
  52684. */
  52685. readonly a: NodeMaterialConnectionPoint;
  52686. protected _buildBlock(state: NodeMaterialBuildState): this;
  52687. }
  52688. }
  52689. declare module BABYLON {
  52690. /**
  52691. * Block used to read a reflection texture from a sampler
  52692. */
  52693. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52694. private _define3DName;
  52695. private _defineCubicName;
  52696. private _defineExplicitName;
  52697. private _defineProjectionName;
  52698. private _defineLocalCubicName;
  52699. private _defineSphericalName;
  52700. private _definePlanarName;
  52701. private _defineEquirectangularName;
  52702. private _defineMirroredEquirectangularFixedName;
  52703. private _defineEquirectangularFixedName;
  52704. private _defineSkyboxName;
  52705. private _cubeSamplerName;
  52706. private _2DSamplerName;
  52707. private _positionUVWName;
  52708. private _directionWName;
  52709. private _reflectionCoordsName;
  52710. private _reflection2DCoordsName;
  52711. private _reflectionColorName;
  52712. private _reflectionMatrixName;
  52713. /**
  52714. * Gets or sets the texture associated with the node
  52715. */
  52716. texture: Nullable<BaseTexture>;
  52717. /**
  52718. * Create a new TextureBlock
  52719. * @param name defines the block name
  52720. */
  52721. constructor(name: string);
  52722. /**
  52723. * Gets the current class name
  52724. * @returns the class name
  52725. */
  52726. getClassName(): string;
  52727. /**
  52728. * Gets the world position input component
  52729. */
  52730. readonly position: NodeMaterialConnectionPoint;
  52731. /**
  52732. * Gets the world position input component
  52733. */
  52734. readonly worldPosition: NodeMaterialConnectionPoint;
  52735. /**
  52736. * Gets the world normal input component
  52737. */
  52738. readonly worldNormal: NodeMaterialConnectionPoint;
  52739. /**
  52740. * Gets the world input component
  52741. */
  52742. readonly world: NodeMaterialConnectionPoint;
  52743. /**
  52744. * Gets the camera (or eye) position component
  52745. */
  52746. readonly cameraPosition: NodeMaterialConnectionPoint;
  52747. /**
  52748. * Gets the view input component
  52749. */
  52750. readonly view: NodeMaterialConnectionPoint;
  52751. /**
  52752. * Gets the rgb output component
  52753. */
  52754. readonly rgb: NodeMaterialConnectionPoint;
  52755. /**
  52756. * Gets the r output component
  52757. */
  52758. readonly r: NodeMaterialConnectionPoint;
  52759. /**
  52760. * Gets the g output component
  52761. */
  52762. readonly g: NodeMaterialConnectionPoint;
  52763. /**
  52764. * Gets the b output component
  52765. */
  52766. readonly b: NodeMaterialConnectionPoint;
  52767. autoConfigure(material: NodeMaterial): void;
  52768. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52769. isReady(): boolean;
  52770. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52771. private _injectVertexCode;
  52772. private _writeOutput;
  52773. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52774. serialize(): any;
  52775. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52776. }
  52777. }
  52778. declare module BABYLON {
  52779. /**
  52780. * Interface used to configure the node material editor
  52781. */
  52782. export interface INodeMaterialEditorOptions {
  52783. /** Define the URl to load node editor script */
  52784. editorURL?: string;
  52785. }
  52786. /** @hidden */
  52787. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52788. /** BONES */
  52789. NUM_BONE_INFLUENCERS: number;
  52790. BonesPerMesh: number;
  52791. BONETEXTURE: boolean;
  52792. /** MORPH TARGETS */
  52793. MORPHTARGETS: boolean;
  52794. MORPHTARGETS_NORMAL: boolean;
  52795. MORPHTARGETS_TANGENT: boolean;
  52796. MORPHTARGETS_UV: boolean;
  52797. NUM_MORPH_INFLUENCERS: number;
  52798. /** IMAGE PROCESSING */
  52799. IMAGEPROCESSING: boolean;
  52800. VIGNETTE: boolean;
  52801. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52802. VIGNETTEBLENDMODEOPAQUE: boolean;
  52803. TONEMAPPING: boolean;
  52804. TONEMAPPING_ACES: boolean;
  52805. CONTRAST: boolean;
  52806. EXPOSURE: boolean;
  52807. COLORCURVES: boolean;
  52808. COLORGRADING: boolean;
  52809. COLORGRADING3D: boolean;
  52810. SAMPLER3DGREENDEPTH: boolean;
  52811. SAMPLER3DBGRMAP: boolean;
  52812. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52813. /** MISC. */
  52814. BUMPDIRECTUV: number;
  52815. constructor();
  52816. setValue(name: string, value: boolean): void;
  52817. }
  52818. /**
  52819. * Class used to configure NodeMaterial
  52820. */
  52821. export interface INodeMaterialOptions {
  52822. /**
  52823. * Defines if blocks should emit comments
  52824. */
  52825. emitComments: boolean;
  52826. }
  52827. /**
  52828. * Class used to create a node based material built by assembling shader blocks
  52829. */
  52830. export class NodeMaterial extends PushMaterial {
  52831. private static _BuildIdGenerator;
  52832. private _options;
  52833. private _vertexCompilationState;
  52834. private _fragmentCompilationState;
  52835. private _sharedData;
  52836. private _buildId;
  52837. private _buildWasSuccessful;
  52838. private _cachedWorldViewMatrix;
  52839. private _cachedWorldViewProjectionMatrix;
  52840. private _optimizers;
  52841. private _animationFrame;
  52842. /** Define the URl to load node editor script */
  52843. static EditorURL: string;
  52844. private BJSNODEMATERIALEDITOR;
  52845. /** Get the inspector from bundle or global */
  52846. private _getGlobalNodeMaterialEditor;
  52847. /**
  52848. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  52849. */
  52850. ignoreAlpha: boolean;
  52851. /**
  52852. * Defines the maximum number of lights that can be used in the material
  52853. */
  52854. maxSimultaneousLights: number;
  52855. /**
  52856. * Observable raised when the material is built
  52857. */
  52858. onBuildObservable: Observable<NodeMaterial>;
  52859. /**
  52860. * Gets or sets the root nodes of the material vertex shader
  52861. */
  52862. _vertexOutputNodes: NodeMaterialBlock[];
  52863. /**
  52864. * Gets or sets the root nodes of the material fragment (pixel) shader
  52865. */
  52866. _fragmentOutputNodes: NodeMaterialBlock[];
  52867. /** Gets or sets options to control the node material overall behavior */
  52868. options: INodeMaterialOptions;
  52869. /**
  52870. * Default configuration related to image processing available in the standard Material.
  52871. */
  52872. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52873. /**
  52874. * Gets the image processing configuration used either in this material.
  52875. */
  52876. /**
  52877. * Sets the Default image processing configuration used either in the this material.
  52878. *
  52879. * If sets to null, the scene one is in use.
  52880. */
  52881. imageProcessingConfiguration: ImageProcessingConfiguration;
  52882. /**
  52883. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52884. */
  52885. attachedBlocks: NodeMaterialBlock[];
  52886. /**
  52887. * Create a new node based material
  52888. * @param name defines the material name
  52889. * @param scene defines the hosting scene
  52890. * @param options defines creation option
  52891. */
  52892. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52893. /**
  52894. * Gets the current class name of the material e.g. "NodeMaterial"
  52895. * @returns the class name
  52896. */
  52897. getClassName(): string;
  52898. /**
  52899. * Keep track of the image processing observer to allow dispose and replace.
  52900. */
  52901. private _imageProcessingObserver;
  52902. /**
  52903. * Attaches a new image processing configuration to the Standard Material.
  52904. * @param configuration
  52905. */
  52906. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52907. /**
  52908. * Get a block by its name
  52909. * @param name defines the name of the block to retrieve
  52910. * @returns the required block or null if not found
  52911. */
  52912. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52913. /**
  52914. * Get a block by its name
  52915. * @param predicate defines the predicate used to find the good candidate
  52916. * @returns the required block or null if not found
  52917. */
  52918. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52919. /**
  52920. * Get an input block by its name
  52921. * @param predicate defines the predicate used to find the good candidate
  52922. * @returns the required input block or null if not found
  52923. */
  52924. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52925. /**
  52926. * Gets the list of input blocks attached to this material
  52927. * @returns an array of InputBlocks
  52928. */
  52929. getInputBlocks(): InputBlock[];
  52930. /**
  52931. * Adds a new optimizer to the list of optimizers
  52932. * @param optimizer defines the optimizers to add
  52933. * @returns the current material
  52934. */
  52935. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52936. /**
  52937. * Remove an optimizer from the list of optimizers
  52938. * @param optimizer defines the optimizers to remove
  52939. * @returns the current material
  52940. */
  52941. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52942. /**
  52943. * Add a new block to the list of output nodes
  52944. * @param node defines the node to add
  52945. * @returns the current material
  52946. */
  52947. addOutputNode(node: NodeMaterialBlock): this;
  52948. /**
  52949. * Remove a block from the list of root nodes
  52950. * @param node defines the node to remove
  52951. * @returns the current material
  52952. */
  52953. removeOutputNode(node: NodeMaterialBlock): this;
  52954. private _addVertexOutputNode;
  52955. private _removeVertexOutputNode;
  52956. private _addFragmentOutputNode;
  52957. private _removeFragmentOutputNode;
  52958. /**
  52959. * Specifies if the material will require alpha blending
  52960. * @returns a boolean specifying if alpha blending is needed
  52961. */
  52962. needAlphaBlending(): boolean;
  52963. /**
  52964. * Specifies if this material should be rendered in alpha test mode
  52965. * @returns a boolean specifying if an alpha test is needed.
  52966. */
  52967. needAlphaTesting(): boolean;
  52968. private _initializeBlock;
  52969. private _resetDualBlocks;
  52970. /**
  52971. * Build the material and generates the inner effect
  52972. * @param verbose defines if the build should log activity
  52973. */
  52974. build(verbose?: boolean): void;
  52975. /**
  52976. * Runs an otpimization phase to try to improve the shader code
  52977. */
  52978. optimize(): void;
  52979. private _prepareDefinesForAttributes;
  52980. /**
  52981. * Get if the submesh is ready to be used and all its information available.
  52982. * Child classes can use it to update shaders
  52983. * @param mesh defines the mesh to check
  52984. * @param subMesh defines which submesh to check
  52985. * @param useInstances specifies that instances should be used
  52986. * @returns a boolean indicating that the submesh is ready or not
  52987. */
  52988. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52989. /**
  52990. * Get a string representing the shaders built by the current node graph
  52991. */
  52992. readonly compiledShaders: string;
  52993. /**
  52994. * Binds the world matrix to the material
  52995. * @param world defines the world transformation matrix
  52996. */
  52997. bindOnlyWorldMatrix(world: Matrix): void;
  52998. /**
  52999. * Binds the submesh to this material by preparing the effect and shader to draw
  53000. * @param world defines the world transformation matrix
  53001. * @param mesh defines the mesh containing the submesh
  53002. * @param subMesh defines the submesh to bind the material to
  53003. */
  53004. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53005. /**
  53006. * Gets the active textures from the material
  53007. * @returns an array of textures
  53008. */
  53009. getActiveTextures(): BaseTexture[];
  53010. /**
  53011. * Gets the list of texture blocks
  53012. * @returns an array of texture blocks
  53013. */
  53014. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  53015. /**
  53016. * Specifies if the material uses a texture
  53017. * @param texture defines the texture to check against the material
  53018. * @returns a boolean specifying if the material uses the texture
  53019. */
  53020. hasTexture(texture: BaseTexture): boolean;
  53021. /**
  53022. * Disposes the material
  53023. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53024. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53025. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53026. */
  53027. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53028. /** Creates the node editor window. */
  53029. private _createNodeEditor;
  53030. /**
  53031. * Launch the node material editor
  53032. * @param config Define the configuration of the editor
  53033. * @return a promise fulfilled when the node editor is visible
  53034. */
  53035. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53036. /**
  53037. * Clear the current material
  53038. */
  53039. clear(): void;
  53040. /**
  53041. * Clear the current material and set it to a default state
  53042. */
  53043. setToDefault(): void;
  53044. /**
  53045. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  53046. * @param url defines the url to load from
  53047. * @returns a promise that will fullfil when the material is fully loaded
  53048. */
  53049. loadAsync(url: string): Promise<unknown>;
  53050. private _gatherBlocks;
  53051. /**
  53052. * Generate a string containing the code declaration required to create an equivalent of this material
  53053. * @returns a string
  53054. */
  53055. generateCode(): string;
  53056. /**
  53057. * Serializes this material in a JSON representation
  53058. * @returns the serialized material object
  53059. */
  53060. serialize(): any;
  53061. private _restoreConnections;
  53062. /**
  53063. * Clear the current graph and load a new one from a serialization object
  53064. * @param source defines the JSON representation of the material
  53065. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53066. */
  53067. loadFromSerialization(source: any, rootUrl?: string): void;
  53068. /**
  53069. * Creates a node material from parsed material data
  53070. * @param source defines the JSON representation of the material
  53071. * @param scene defines the hosting scene
  53072. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53073. * @returns a new node material
  53074. */
  53075. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53076. /**
  53077. * Creates a new node material set to default basic configuration
  53078. * @param name defines the name of the material
  53079. * @param scene defines the hosting scene
  53080. * @returns a new NodeMaterial
  53081. */
  53082. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  53083. }
  53084. }
  53085. declare module BABYLON {
  53086. /**
  53087. * Block used to read a texture from a sampler
  53088. */
  53089. export class TextureBlock extends NodeMaterialBlock {
  53090. private _defineName;
  53091. private _linearDefineName;
  53092. private _samplerName;
  53093. private _transformedUVName;
  53094. private _textureTransformName;
  53095. private _textureInfoName;
  53096. private _mainUVName;
  53097. private _mainUVDefineName;
  53098. /**
  53099. * Gets or sets the texture associated with the node
  53100. */
  53101. texture: Nullable<Texture>;
  53102. /**
  53103. * Create a new TextureBlock
  53104. * @param name defines the block name
  53105. */
  53106. constructor(name: string);
  53107. /**
  53108. * Gets the current class name
  53109. * @returns the class name
  53110. */
  53111. getClassName(): string;
  53112. /**
  53113. * Gets the uv input component
  53114. */
  53115. readonly uv: NodeMaterialConnectionPoint;
  53116. /**
  53117. * Gets the rgba output component
  53118. */
  53119. readonly rgba: NodeMaterialConnectionPoint;
  53120. /**
  53121. * Gets the rgb output component
  53122. */
  53123. readonly rgb: NodeMaterialConnectionPoint;
  53124. /**
  53125. * Gets the r output component
  53126. */
  53127. readonly r: NodeMaterialConnectionPoint;
  53128. /**
  53129. * Gets the g output component
  53130. */
  53131. readonly g: NodeMaterialConnectionPoint;
  53132. /**
  53133. * Gets the b output component
  53134. */
  53135. readonly b: NodeMaterialConnectionPoint;
  53136. /**
  53137. * Gets the a output component
  53138. */
  53139. readonly a: NodeMaterialConnectionPoint;
  53140. readonly target: NodeMaterialBlockTargets;
  53141. autoConfigure(material: NodeMaterial): void;
  53142. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53143. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53144. isReady(): boolean;
  53145. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53146. private readonly _isMixed;
  53147. private _injectVertexCode;
  53148. private _writeOutput;
  53149. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53150. protected _dumpPropertiesCode(): string;
  53151. serialize(): any;
  53152. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53153. }
  53154. }
  53155. declare module BABYLON {
  53156. /**
  53157. * Class used to store shared data between 2 NodeMaterialBuildState
  53158. */
  53159. export class NodeMaterialBuildStateSharedData {
  53160. /**
  53161. * Gets the list of emitted varyings
  53162. */
  53163. temps: string[];
  53164. /**
  53165. * Gets the list of emitted varyings
  53166. */
  53167. varyings: string[];
  53168. /**
  53169. * Gets the varying declaration string
  53170. */
  53171. varyingDeclaration: string;
  53172. /**
  53173. * Input blocks
  53174. */
  53175. inputBlocks: InputBlock[];
  53176. /**
  53177. * Input blocks
  53178. */
  53179. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  53180. /**
  53181. * Bindable blocks (Blocks that need to set data to the effect)
  53182. */
  53183. bindableBlocks: NodeMaterialBlock[];
  53184. /**
  53185. * List of blocks that can provide a compilation fallback
  53186. */
  53187. blocksWithFallbacks: NodeMaterialBlock[];
  53188. /**
  53189. * List of blocks that can provide a define update
  53190. */
  53191. blocksWithDefines: NodeMaterialBlock[];
  53192. /**
  53193. * List of blocks that can provide a repeatable content
  53194. */
  53195. repeatableContentBlocks: NodeMaterialBlock[];
  53196. /**
  53197. * List of blocks that can provide a dynamic list of uniforms
  53198. */
  53199. dynamicUniformBlocks: NodeMaterialBlock[];
  53200. /**
  53201. * List of blocks that can block the isReady function for the material
  53202. */
  53203. blockingBlocks: NodeMaterialBlock[];
  53204. /**
  53205. * Gets the list of animated inputs
  53206. */
  53207. animatedInputs: InputBlock[];
  53208. /**
  53209. * Build Id used to avoid multiple recompilations
  53210. */
  53211. buildId: number;
  53212. /** List of emitted variables */
  53213. variableNames: {
  53214. [key: string]: number;
  53215. };
  53216. /** List of emitted defines */
  53217. defineNames: {
  53218. [key: string]: number;
  53219. };
  53220. /** Should emit comments? */
  53221. emitComments: boolean;
  53222. /** Emit build activity */
  53223. verbose: boolean;
  53224. /** Gets or sets the hosting scene */
  53225. scene: Scene;
  53226. /**
  53227. * Gets the compilation hints emitted at compilation time
  53228. */
  53229. hints: {
  53230. needWorldViewMatrix: boolean;
  53231. needWorldViewProjectionMatrix: boolean;
  53232. needAlphaBlending: boolean;
  53233. needAlphaTesting: boolean;
  53234. };
  53235. /**
  53236. * List of compilation checks
  53237. */
  53238. checks: {
  53239. emitVertex: boolean;
  53240. emitFragment: boolean;
  53241. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53242. };
  53243. /** Creates a new shared data */
  53244. constructor();
  53245. /**
  53246. * Emits console errors and exceptions if there is a failing check
  53247. */
  53248. emitErrors(): void;
  53249. }
  53250. }
  53251. declare module BABYLON {
  53252. /**
  53253. * Class used to store node based material build state
  53254. */
  53255. export class NodeMaterialBuildState {
  53256. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53257. supportUniformBuffers: boolean;
  53258. /**
  53259. * Gets the list of emitted attributes
  53260. */
  53261. attributes: string[];
  53262. /**
  53263. * Gets the list of emitted uniforms
  53264. */
  53265. uniforms: string[];
  53266. /**
  53267. * Gets the list of emitted constants
  53268. */
  53269. constants: string[];
  53270. /**
  53271. * Gets the list of emitted uniform buffers
  53272. */
  53273. uniformBuffers: string[];
  53274. /**
  53275. * Gets the list of emitted samplers
  53276. */
  53277. samplers: string[];
  53278. /**
  53279. * Gets the list of emitted functions
  53280. */
  53281. functions: {
  53282. [key: string]: string;
  53283. };
  53284. /**
  53285. * Gets the list of emitted extensions
  53286. */
  53287. extensions: {
  53288. [key: string]: string;
  53289. };
  53290. /**
  53291. * Gets the target of the compilation state
  53292. */
  53293. target: NodeMaterialBlockTargets;
  53294. /**
  53295. * Gets the list of emitted counters
  53296. */
  53297. counters: {
  53298. [key: string]: number;
  53299. };
  53300. /**
  53301. * Shared data between multiple NodeMaterialBuildState instances
  53302. */
  53303. sharedData: NodeMaterialBuildStateSharedData;
  53304. /** @hidden */
  53305. _vertexState: NodeMaterialBuildState;
  53306. /** @hidden */
  53307. _attributeDeclaration: string;
  53308. /** @hidden */
  53309. _uniformDeclaration: string;
  53310. /** @hidden */
  53311. _constantDeclaration: string;
  53312. /** @hidden */
  53313. _samplerDeclaration: string;
  53314. /** @hidden */
  53315. _varyingTransfer: string;
  53316. private _repeatableContentAnchorIndex;
  53317. /** @hidden */
  53318. _builtCompilationString: string;
  53319. /**
  53320. * Gets the emitted compilation strings
  53321. */
  53322. compilationString: string;
  53323. /**
  53324. * Finalize the compilation strings
  53325. * @param state defines the current compilation state
  53326. */
  53327. finalize(state: NodeMaterialBuildState): void;
  53328. /** @hidden */
  53329. readonly _repeatableContentAnchor: string;
  53330. /** @hidden */
  53331. _getFreeVariableName(prefix: string): string;
  53332. /** @hidden */
  53333. _getFreeDefineName(prefix: string): string;
  53334. /** @hidden */
  53335. _excludeVariableName(name: string): void;
  53336. /** @hidden */
  53337. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53338. /** @hidden */
  53339. _emitExtension(name: string, extension: string): void;
  53340. /** @hidden */
  53341. _emitFunction(name: string, code: string, comments: string): void;
  53342. /** @hidden */
  53343. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53344. replaceStrings?: {
  53345. search: RegExp;
  53346. replace: string;
  53347. }[];
  53348. repeatKey?: string;
  53349. }): string;
  53350. /** @hidden */
  53351. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53352. repeatKey?: string;
  53353. removeAttributes?: boolean;
  53354. removeUniforms?: boolean;
  53355. removeVaryings?: boolean;
  53356. removeIfDef?: boolean;
  53357. replaceStrings?: {
  53358. search: RegExp;
  53359. replace: string;
  53360. }[];
  53361. }, storeKey?: string): void;
  53362. /** @hidden */
  53363. _registerTempVariable(name: string): boolean;
  53364. /** @hidden */
  53365. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  53366. /** @hidden */
  53367. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  53368. /** @hidden */
  53369. _emitFloat(value: number): string;
  53370. }
  53371. }
  53372. declare module BABYLON {
  53373. /**
  53374. * Defines a block that can be used inside a node based material
  53375. */
  53376. export class NodeMaterialBlock {
  53377. private _buildId;
  53378. private _buildTarget;
  53379. private _target;
  53380. private _isFinalMerger;
  53381. private _isInput;
  53382. /** @hidden */
  53383. _codeVariableName: string;
  53384. /** @hidden */
  53385. _inputs: NodeMaterialConnectionPoint[];
  53386. /** @hidden */
  53387. _outputs: NodeMaterialConnectionPoint[];
  53388. /** @hidden */
  53389. _preparationId: number;
  53390. /**
  53391. * Gets or sets the name of the block
  53392. */
  53393. name: string;
  53394. /**
  53395. * Gets or sets the unique id of the node
  53396. */
  53397. uniqueId: number;
  53398. /**
  53399. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53400. */
  53401. readonly isFinalMerger: boolean;
  53402. /**
  53403. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  53404. */
  53405. readonly isInput: boolean;
  53406. /**
  53407. * Gets or sets the build Id
  53408. */
  53409. buildId: number;
  53410. /**
  53411. * Gets or sets the target of the block
  53412. */
  53413. target: NodeMaterialBlockTargets;
  53414. /**
  53415. * Gets the list of input points
  53416. */
  53417. readonly inputs: NodeMaterialConnectionPoint[];
  53418. /** Gets the list of output points */
  53419. readonly outputs: NodeMaterialConnectionPoint[];
  53420. /**
  53421. * Find an input by its name
  53422. * @param name defines the name of the input to look for
  53423. * @returns the input or null if not found
  53424. */
  53425. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53426. /**
  53427. * Find an output by its name
  53428. * @param name defines the name of the outputto look for
  53429. * @returns the output or null if not found
  53430. */
  53431. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53432. /**
  53433. * Creates a new NodeMaterialBlock
  53434. * @param name defines the block name
  53435. * @param target defines the target of that block (Vertex by default)
  53436. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53437. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  53438. */
  53439. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  53440. /**
  53441. * Initialize the block and prepare the context for build
  53442. * @param state defines the state that will be used for the build
  53443. */
  53444. initialize(state: NodeMaterialBuildState): void;
  53445. /**
  53446. * Bind data to effect. Will only be called for blocks with isBindable === true
  53447. * @param effect defines the effect to bind data to
  53448. * @param nodeMaterial defines the hosting NodeMaterial
  53449. * @param mesh defines the mesh that will be rendered
  53450. */
  53451. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53452. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53453. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53454. protected _writeFloat(value: number): string;
  53455. /**
  53456. * Gets the current class name e.g. "NodeMaterialBlock"
  53457. * @returns the class name
  53458. */
  53459. getClassName(): string;
  53460. /**
  53461. * Register a new input. Must be called inside a block constructor
  53462. * @param name defines the connection point name
  53463. * @param type defines the connection point type
  53464. * @param isOptional defines a boolean indicating that this input can be omitted
  53465. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53466. * @returns the current block
  53467. */
  53468. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53469. /**
  53470. * Register a new output. Must be called inside a block constructor
  53471. * @param name defines the connection point name
  53472. * @param type defines the connection point type
  53473. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53474. * @returns the current block
  53475. */
  53476. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53477. /**
  53478. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53479. * @param forOutput defines an optional connection point to check compatibility with
  53480. * @returns the first available input or null
  53481. */
  53482. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53483. /**
  53484. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53485. * @param forBlock defines an optional block to check compatibility with
  53486. * @returns the first available input or null
  53487. */
  53488. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53489. /**
  53490. * Gets the sibling of the given output
  53491. * @param current defines the current output
  53492. * @returns the next output in the list or null
  53493. */
  53494. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  53495. /**
  53496. * Connect current block with another block
  53497. * @param other defines the block to connect with
  53498. * @param options define the various options to help pick the right connections
  53499. * @returns the current block
  53500. */
  53501. connectTo(other: NodeMaterialBlock, options?: {
  53502. input?: string;
  53503. output?: string;
  53504. outputSwizzle?: string;
  53505. }): this | undefined;
  53506. protected _buildBlock(state: NodeMaterialBuildState): void;
  53507. /**
  53508. * Add uniforms, samplers and uniform buffers at compilation time
  53509. * @param state defines the state to update
  53510. * @param nodeMaterial defines the node material requesting the update
  53511. * @param defines defines the material defines to update
  53512. */
  53513. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53514. /**
  53515. * Add potential fallbacks if shader compilation fails
  53516. * @param mesh defines the mesh to be rendered
  53517. * @param fallbacks defines the current prioritized list of fallbacks
  53518. */
  53519. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53520. /**
  53521. * Initialize defines for shader compilation
  53522. * @param mesh defines the mesh to be rendered
  53523. * @param nodeMaterial defines the node material requesting the update
  53524. * @param defines defines the material defines to update
  53525. * @param useInstances specifies that instances should be used
  53526. */
  53527. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53528. /**
  53529. * Update defines for shader compilation
  53530. * @param mesh defines the mesh to be rendered
  53531. * @param nodeMaterial defines the node material requesting the update
  53532. * @param defines defines the material defines to update
  53533. * @param useInstances specifies that instances should be used
  53534. */
  53535. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53536. /**
  53537. * Lets the block try to connect some inputs automatically
  53538. * @param material defines the hosting NodeMaterial
  53539. */
  53540. autoConfigure(material: NodeMaterial): void;
  53541. /**
  53542. * Function called when a block is declared as repeatable content generator
  53543. * @param vertexShaderState defines the current compilation state for the vertex shader
  53544. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53545. * @param mesh defines the mesh to be rendered
  53546. * @param defines defines the material defines to update
  53547. */
  53548. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53549. /**
  53550. * Checks if the block is ready
  53551. * @param mesh defines the mesh to be rendered
  53552. * @param nodeMaterial defines the node material requesting the update
  53553. * @param defines defines the material defines to update
  53554. * @param useInstances specifies that instances should be used
  53555. * @returns true if the block is ready
  53556. */
  53557. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53558. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53559. private _processBuild;
  53560. /**
  53561. * Compile the current node and generate the shader code
  53562. * @param state defines the current compilation state (uniforms, samplers, current string)
  53563. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53564. * @returns true if already built
  53565. */
  53566. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53567. protected _inputRename(name: string): string;
  53568. protected _outputRename(name: string): string;
  53569. protected _dumpPropertiesCode(): string;
  53570. /** @hidden */
  53571. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53572. /**
  53573. * Clone the current block to a new identical block
  53574. * @param scene defines the hosting scene
  53575. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53576. * @returns a copy of the current block
  53577. */
  53578. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53579. /**
  53580. * Serializes this block in a JSON representation
  53581. * @returns the serialized block object
  53582. */
  53583. serialize(): any;
  53584. /** @hidden */
  53585. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53586. }
  53587. }
  53588. declare module BABYLON {
  53589. /**
  53590. * Enum defining the type of animations supported by InputBlock
  53591. */
  53592. export enum AnimatedInputBlockTypes {
  53593. /** No animation */
  53594. None = 0,
  53595. /** Time based animation. Will only work for floats */
  53596. Time = 1
  53597. }
  53598. }
  53599. declare module BABYLON {
  53600. /**
  53601. * Block used to expose an input value
  53602. */
  53603. export class InputBlock extends NodeMaterialBlock {
  53604. private _mode;
  53605. private _associatedVariableName;
  53606. private _storedValue;
  53607. private _valueCallback;
  53608. private _type;
  53609. private _animationType;
  53610. /** Gets or set a value used to limit the range of float values */
  53611. min: number;
  53612. /** Gets or set a value used to limit the range of float values */
  53613. max: number;
  53614. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  53615. matrixMode: number;
  53616. /** @hidden */
  53617. _systemValue: Nullable<NodeMaterialSystemValues>;
  53618. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53619. visibleInInspector: boolean;
  53620. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  53621. isConstant: boolean;
  53622. /**
  53623. * Gets or sets the connection point type (default is float)
  53624. */
  53625. readonly type: NodeMaterialBlockConnectionPointTypes;
  53626. /**
  53627. * Creates a new InputBlock
  53628. * @param name defines the block name
  53629. * @param target defines the target of that block (Vertex by default)
  53630. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53631. */
  53632. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53633. /**
  53634. * Gets the output component
  53635. */
  53636. readonly output: NodeMaterialConnectionPoint;
  53637. /**
  53638. * Set the source of this connection point to a vertex attribute
  53639. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53640. * @returns the current connection point
  53641. */
  53642. setAsAttribute(attributeName?: string): InputBlock;
  53643. /**
  53644. * Set the source of this connection point to a system value
  53645. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53646. * @returns the current connection point
  53647. */
  53648. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53649. /**
  53650. * Gets or sets the value of that point.
  53651. * Please note that this value will be ignored if valueCallback is defined
  53652. */
  53653. value: any;
  53654. /**
  53655. * Gets or sets a callback used to get the value of that point.
  53656. * Please note that setting this value will force the connection point to ignore the value property
  53657. */
  53658. valueCallback: () => any;
  53659. /**
  53660. * Gets or sets the associated variable name in the shader
  53661. */
  53662. associatedVariableName: string;
  53663. /** Gets or sets the type of animation applied to the input */
  53664. animationType: AnimatedInputBlockTypes;
  53665. /**
  53666. * Gets a boolean indicating that this connection point not defined yet
  53667. */
  53668. readonly isUndefined: boolean;
  53669. /**
  53670. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53671. * In this case the connection point name must be the name of the uniform to use.
  53672. * Can only be set on inputs
  53673. */
  53674. isUniform: boolean;
  53675. /**
  53676. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53677. * In this case the connection point name must be the name of the attribute to use
  53678. * Can only be set on inputs
  53679. */
  53680. isAttribute: boolean;
  53681. /**
  53682. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53683. * Can only be set on exit points
  53684. */
  53685. isVarying: boolean;
  53686. /**
  53687. * Gets a boolean indicating that the current connection point is a system value
  53688. */
  53689. readonly isSystemValue: boolean;
  53690. /**
  53691. * Gets or sets the current well known value or null if not defined as a system value
  53692. */
  53693. systemValue: Nullable<NodeMaterialSystemValues>;
  53694. /**
  53695. * Gets the current class name
  53696. * @returns the class name
  53697. */
  53698. getClassName(): string;
  53699. /**
  53700. * Animate the input if animationType !== None
  53701. * @param scene defines the rendering scene
  53702. */
  53703. animate(scene: Scene): void;
  53704. private _emitDefine;
  53705. initialize(state: NodeMaterialBuildState): void;
  53706. /**
  53707. * Set the input block to its default value (based on its type)
  53708. */
  53709. setDefaultValue(): void;
  53710. private _emitConstant;
  53711. private _emit;
  53712. /** @hidden */
  53713. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53714. /** @hidden */
  53715. _transmit(effect: Effect, scene: Scene): void;
  53716. protected _buildBlock(state: NodeMaterialBuildState): void;
  53717. protected _dumpPropertiesCode(): string;
  53718. serialize(): any;
  53719. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53720. }
  53721. }
  53722. declare module BABYLON {
  53723. /**
  53724. * Defines a connection point for a block
  53725. */
  53726. export class NodeMaterialConnectionPoint {
  53727. /** @hidden */
  53728. _ownerBlock: NodeMaterialBlock;
  53729. /** @hidden */
  53730. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53731. private _endpoints;
  53732. private _associatedVariableName;
  53733. /** @hidden */
  53734. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53735. /** @hidden */
  53736. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53737. private _type;
  53738. /** @hidden */
  53739. _enforceAssociatedVariableName: boolean;
  53740. /**
  53741. * Gets or sets the additional types supported by this connection point
  53742. */
  53743. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53744. /**
  53745. * Gets or sets the additional types excluded by this connection point
  53746. */
  53747. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53748. /**
  53749. * Gets or sets the associated variable name in the shader
  53750. */
  53751. associatedVariableName: string;
  53752. /**
  53753. * Gets or sets the connection point type (default is float)
  53754. */
  53755. type: NodeMaterialBlockConnectionPointTypes;
  53756. /**
  53757. * Gets or sets the connection point name
  53758. */
  53759. name: string;
  53760. /**
  53761. * Gets or sets a boolean indicating that this connection point can be omitted
  53762. */
  53763. isOptional: boolean;
  53764. /**
  53765. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53766. */
  53767. define: string;
  53768. /** Gets or sets the target of that connection point */
  53769. target: NodeMaterialBlockTargets;
  53770. /**
  53771. * Gets a boolean indicating that the current point is connected
  53772. */
  53773. readonly isConnected: boolean;
  53774. /**
  53775. * Gets a boolean indicating that the current point is connected to an input block
  53776. */
  53777. readonly isConnectedToInputBlock: boolean;
  53778. /**
  53779. * Gets a the connected input block (if any)
  53780. */
  53781. readonly connectInputBlock: Nullable<InputBlock>;
  53782. /** Get the other side of the connection (if any) */
  53783. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53784. /** Get the block that owns this connection point */
  53785. readonly ownerBlock: NodeMaterialBlock;
  53786. /** Get the block connected on the other side of this connection (if any) */
  53787. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53788. /** Get the block connected on the endpoints of this connection (if any) */
  53789. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53790. /** Gets the list of connected endpoints */
  53791. readonly endpoints: NodeMaterialConnectionPoint[];
  53792. /** Gets a boolean indicating if that output point is connected to at least one input */
  53793. readonly hasEndpoints: boolean;
  53794. /**
  53795. * Creates a new connection point
  53796. * @param name defines the connection point name
  53797. * @param ownerBlock defines the block hosting this connection point
  53798. */
  53799. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53800. /**
  53801. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53802. * @returns the class name
  53803. */
  53804. getClassName(): string;
  53805. /**
  53806. * Gets an boolean indicating if the current point can be connected to another point
  53807. * @param connectionPoint defines the other connection point
  53808. * @returns true if the connection is possible
  53809. */
  53810. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53811. /**
  53812. * Connect this point to another connection point
  53813. * @param connectionPoint defines the other connection point
  53814. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53815. * @returns the current connection point
  53816. */
  53817. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53818. /**
  53819. * Disconnect this point from one of his endpoint
  53820. * @param endpoint defines the other connection point
  53821. * @returns the current connection point
  53822. */
  53823. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53824. /**
  53825. * Serializes this point in a JSON representation
  53826. * @returns the serialized point object
  53827. */
  53828. serialize(): any;
  53829. }
  53830. }
  53831. declare module BABYLON {
  53832. /**
  53833. * Block used to add support for vertex skinning (bones)
  53834. */
  53835. export class BonesBlock extends NodeMaterialBlock {
  53836. /**
  53837. * Creates a new BonesBlock
  53838. * @param name defines the block name
  53839. */
  53840. constructor(name: string);
  53841. /**
  53842. * Initialize the block and prepare the context for build
  53843. * @param state defines the state that will be used for the build
  53844. */
  53845. initialize(state: NodeMaterialBuildState): void;
  53846. /**
  53847. * Gets the current class name
  53848. * @returns the class name
  53849. */
  53850. getClassName(): string;
  53851. /**
  53852. * Gets the matrix indices input component
  53853. */
  53854. readonly matricesIndices: NodeMaterialConnectionPoint;
  53855. /**
  53856. * Gets the matrix weights input component
  53857. */
  53858. readonly matricesWeights: NodeMaterialConnectionPoint;
  53859. /**
  53860. * Gets the extra matrix indices input component
  53861. */
  53862. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53863. /**
  53864. * Gets the extra matrix weights input component
  53865. */
  53866. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53867. /**
  53868. * Gets the world input component
  53869. */
  53870. readonly world: NodeMaterialConnectionPoint;
  53871. /**
  53872. * Gets the output component
  53873. */
  53874. readonly output: NodeMaterialConnectionPoint;
  53875. autoConfigure(material: NodeMaterial): void;
  53876. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53877. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53878. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53879. protected _buildBlock(state: NodeMaterialBuildState): this;
  53880. }
  53881. }
  53882. declare module BABYLON {
  53883. /**
  53884. * Block used to add support for instances
  53885. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53886. */
  53887. export class InstancesBlock extends NodeMaterialBlock {
  53888. /**
  53889. * Creates a new InstancesBlock
  53890. * @param name defines the block name
  53891. */
  53892. constructor(name: string);
  53893. /**
  53894. * Gets the current class name
  53895. * @returns the class name
  53896. */
  53897. getClassName(): string;
  53898. /**
  53899. * Gets the first world row input component
  53900. */
  53901. readonly world0: NodeMaterialConnectionPoint;
  53902. /**
  53903. * Gets the second world row input component
  53904. */
  53905. readonly world1: NodeMaterialConnectionPoint;
  53906. /**
  53907. * Gets the third world row input component
  53908. */
  53909. readonly world2: NodeMaterialConnectionPoint;
  53910. /**
  53911. * Gets the forth world row input component
  53912. */
  53913. readonly world3: NodeMaterialConnectionPoint;
  53914. /**
  53915. * Gets the world input component
  53916. */
  53917. readonly world: NodeMaterialConnectionPoint;
  53918. /**
  53919. * Gets the output component
  53920. */
  53921. readonly output: NodeMaterialConnectionPoint;
  53922. autoConfigure(material: NodeMaterial): void;
  53923. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53924. protected _buildBlock(state: NodeMaterialBuildState): this;
  53925. }
  53926. }
  53927. declare module BABYLON {
  53928. /**
  53929. * Block used to add morph targets support to vertex shader
  53930. */
  53931. export class MorphTargetsBlock extends NodeMaterialBlock {
  53932. private _repeatableContentAnchor;
  53933. private _repeatebleContentGenerated;
  53934. /**
  53935. * Create a new MorphTargetsBlock
  53936. * @param name defines the block name
  53937. */
  53938. constructor(name: string);
  53939. /**
  53940. * Gets the current class name
  53941. * @returns the class name
  53942. */
  53943. getClassName(): string;
  53944. /**
  53945. * Gets the position input component
  53946. */
  53947. readonly position: NodeMaterialConnectionPoint;
  53948. /**
  53949. * Gets the normal input component
  53950. */
  53951. readonly normal: NodeMaterialConnectionPoint;
  53952. /**
  53953. * Gets the tangent input component
  53954. */
  53955. readonly tangent: NodeMaterialConnectionPoint;
  53956. /**
  53957. * Gets the tangent input component
  53958. */
  53959. readonly uv: NodeMaterialConnectionPoint;
  53960. /**
  53961. * Gets the position output component
  53962. */
  53963. readonly positionOutput: NodeMaterialConnectionPoint;
  53964. /**
  53965. * Gets the normal output component
  53966. */
  53967. readonly normalOutput: NodeMaterialConnectionPoint;
  53968. /**
  53969. * Gets the tangent output component
  53970. */
  53971. readonly tangentOutput: NodeMaterialConnectionPoint;
  53972. /**
  53973. * Gets the tangent output component
  53974. */
  53975. readonly uvOutput: NodeMaterialConnectionPoint;
  53976. initialize(state: NodeMaterialBuildState): void;
  53977. autoConfigure(material: NodeMaterial): void;
  53978. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53979. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53980. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53981. protected _buildBlock(state: NodeMaterialBuildState): this;
  53982. }
  53983. }
  53984. declare module BABYLON {
  53985. /**
  53986. * Block used to get data information from a light
  53987. */
  53988. export class LightInformationBlock extends NodeMaterialBlock {
  53989. private _lightDataUniformName;
  53990. private _lightColorUniformName;
  53991. private _lightTypeDefineName;
  53992. /**
  53993. * Gets or sets the light associated with this block
  53994. */
  53995. light: Nullable<Light>;
  53996. /**
  53997. * Creates a new LightInformationBlock
  53998. * @param name defines the block name
  53999. */
  54000. constructor(name: string);
  54001. /**
  54002. * Gets the current class name
  54003. * @returns the class name
  54004. */
  54005. getClassName(): string;
  54006. /**
  54007. * Gets the world position input component
  54008. */
  54009. readonly worldPosition: NodeMaterialConnectionPoint;
  54010. /**
  54011. * Gets the direction output component
  54012. */
  54013. readonly direction: NodeMaterialConnectionPoint;
  54014. /**
  54015. * Gets the direction output component
  54016. */
  54017. readonly color: NodeMaterialConnectionPoint;
  54018. /**
  54019. * Gets the direction output component
  54020. */
  54021. readonly intensity: NodeMaterialConnectionPoint;
  54022. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54023. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54024. protected _buildBlock(state: NodeMaterialBuildState): this;
  54025. serialize(): any;
  54026. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54027. }
  54028. }
  54029. declare module BABYLON {
  54030. /**
  54031. * Block used to add image processing support to fragment shader
  54032. */
  54033. export class ImageProcessingBlock extends NodeMaterialBlock {
  54034. /**
  54035. * Create a new ImageProcessingBlock
  54036. * @param name defines the block name
  54037. */
  54038. constructor(name: string);
  54039. /**
  54040. * Gets the current class name
  54041. * @returns the class name
  54042. */
  54043. getClassName(): string;
  54044. /**
  54045. * Gets the color input component
  54046. */
  54047. readonly color: NodeMaterialConnectionPoint;
  54048. /**
  54049. * Gets the output component
  54050. */
  54051. readonly output: NodeMaterialConnectionPoint;
  54052. /**
  54053. * Initialize the block and prepare the context for build
  54054. * @param state defines the state that will be used for the build
  54055. */
  54056. initialize(state: NodeMaterialBuildState): void;
  54057. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54058. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54059. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54060. protected _buildBlock(state: NodeMaterialBuildState): this;
  54061. }
  54062. }
  54063. declare module BABYLON {
  54064. /**
  54065. * Block used to pertub normals based on a normal map
  54066. */
  54067. export class PerturbNormalBlock extends NodeMaterialBlock {
  54068. private _tangentSpaceParameterName;
  54069. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  54070. invertX: boolean;
  54071. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  54072. invertY: boolean;
  54073. /**
  54074. * Create a new PerturbNormalBlock
  54075. * @param name defines the block name
  54076. */
  54077. constructor(name: string);
  54078. /**
  54079. * Gets the current class name
  54080. * @returns the class name
  54081. */
  54082. getClassName(): string;
  54083. /**
  54084. * Gets the world position input component
  54085. */
  54086. readonly worldPosition: NodeMaterialConnectionPoint;
  54087. /**
  54088. * Gets the world normal input component
  54089. */
  54090. readonly worldNormal: NodeMaterialConnectionPoint;
  54091. /**
  54092. * Gets the uv input component
  54093. */
  54094. readonly uv: NodeMaterialConnectionPoint;
  54095. /**
  54096. * Gets the normal map color input component
  54097. */
  54098. readonly normalMapColor: NodeMaterialConnectionPoint;
  54099. /**
  54100. * Gets the strength input component
  54101. */
  54102. readonly strength: NodeMaterialConnectionPoint;
  54103. /**
  54104. * Gets the output component
  54105. */
  54106. readonly output: NodeMaterialConnectionPoint;
  54107. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54108. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54109. autoConfigure(material: NodeMaterial): void;
  54110. protected _buildBlock(state: NodeMaterialBuildState): this;
  54111. protected _dumpPropertiesCode(): string;
  54112. serialize(): any;
  54113. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54114. }
  54115. }
  54116. declare module BABYLON {
  54117. /**
  54118. * Block used to discard a pixel if a value is smaller than a cutoff
  54119. */
  54120. export class DiscardBlock extends NodeMaterialBlock {
  54121. /**
  54122. * Create a new DiscardBlock
  54123. * @param name defines the block name
  54124. */
  54125. constructor(name: string);
  54126. /**
  54127. * Gets the current class name
  54128. * @returns the class name
  54129. */
  54130. getClassName(): string;
  54131. /**
  54132. * Gets the color input component
  54133. */
  54134. readonly value: NodeMaterialConnectionPoint;
  54135. /**
  54136. * Gets the cutoff input component
  54137. */
  54138. readonly cutoff: NodeMaterialConnectionPoint;
  54139. protected _buildBlock(state: NodeMaterialBuildState): this;
  54140. }
  54141. }
  54142. declare module BABYLON {
  54143. /**
  54144. * Block used to add support for scene fog
  54145. */
  54146. export class FogBlock extends NodeMaterialBlock {
  54147. private _fogDistanceName;
  54148. private _fogParameters;
  54149. /**
  54150. * Create a new FogBlock
  54151. * @param name defines the block name
  54152. */
  54153. constructor(name: string);
  54154. /**
  54155. * Gets the current class name
  54156. * @returns the class name
  54157. */
  54158. getClassName(): string;
  54159. /**
  54160. * Gets the world position input component
  54161. */
  54162. readonly worldPosition: NodeMaterialConnectionPoint;
  54163. /**
  54164. * Gets the view input component
  54165. */
  54166. readonly view: NodeMaterialConnectionPoint;
  54167. /**
  54168. * Gets the color input component
  54169. */
  54170. readonly input: NodeMaterialConnectionPoint;
  54171. /**
  54172. * Gets the fog color input component
  54173. */
  54174. readonly fogColor: NodeMaterialConnectionPoint;
  54175. /**
  54176. * Gets the output component
  54177. */
  54178. readonly output: NodeMaterialConnectionPoint;
  54179. autoConfigure(material: NodeMaterial): void;
  54180. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54181. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54182. protected _buildBlock(state: NodeMaterialBuildState): this;
  54183. }
  54184. }
  54185. declare module BABYLON {
  54186. /**
  54187. * Block used to add light in the fragment shader
  54188. */
  54189. export class LightBlock extends NodeMaterialBlock {
  54190. private _lightId;
  54191. /**
  54192. * Gets or sets the light associated with this block
  54193. */
  54194. light: Nullable<Light>;
  54195. /**
  54196. * Create a new LightBlock
  54197. * @param name defines the block name
  54198. */
  54199. constructor(name: string);
  54200. /**
  54201. * Gets the current class name
  54202. * @returns the class name
  54203. */
  54204. getClassName(): string;
  54205. /**
  54206. * Gets the world position input component
  54207. */
  54208. readonly worldPosition: NodeMaterialConnectionPoint;
  54209. /**
  54210. * Gets the world normal input component
  54211. */
  54212. readonly worldNormal: NodeMaterialConnectionPoint;
  54213. /**
  54214. * Gets the camera (or eye) position component
  54215. */
  54216. readonly cameraPosition: NodeMaterialConnectionPoint;
  54217. /**
  54218. * Gets the glossiness component
  54219. */
  54220. readonly glossiness: NodeMaterialConnectionPoint;
  54221. /**
  54222. * Gets the glossinness power component
  54223. */
  54224. readonly glossPower: NodeMaterialConnectionPoint;
  54225. /**
  54226. * Gets the diffuse color component
  54227. */
  54228. readonly diffuseColor: NodeMaterialConnectionPoint;
  54229. /**
  54230. * Gets the specular color component
  54231. */
  54232. readonly specularColor: NodeMaterialConnectionPoint;
  54233. /**
  54234. * Gets the diffuse output component
  54235. */
  54236. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54237. /**
  54238. * Gets the specular output component
  54239. */
  54240. readonly specularOutput: NodeMaterialConnectionPoint;
  54241. autoConfigure(material: NodeMaterial): void;
  54242. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54243. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54244. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54245. private _injectVertexCode;
  54246. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54247. serialize(): any;
  54248. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54249. }
  54250. }
  54251. declare module BABYLON {
  54252. /**
  54253. * Block used to multiply 2 values
  54254. */
  54255. export class MultiplyBlock extends NodeMaterialBlock {
  54256. /**
  54257. * Creates a new MultiplyBlock
  54258. * @param name defines the block name
  54259. */
  54260. constructor(name: string);
  54261. /**
  54262. * Gets the current class name
  54263. * @returns the class name
  54264. */
  54265. getClassName(): string;
  54266. /**
  54267. * Gets the left operand input component
  54268. */
  54269. readonly left: NodeMaterialConnectionPoint;
  54270. /**
  54271. * Gets the right operand input component
  54272. */
  54273. readonly right: NodeMaterialConnectionPoint;
  54274. /**
  54275. * Gets the output component
  54276. */
  54277. readonly output: NodeMaterialConnectionPoint;
  54278. protected _buildBlock(state: NodeMaterialBuildState): this;
  54279. }
  54280. }
  54281. declare module BABYLON {
  54282. /**
  54283. * Block used to add 2 vectors
  54284. */
  54285. export class AddBlock extends NodeMaterialBlock {
  54286. /**
  54287. * Creates a new AddBlock
  54288. * @param name defines the block name
  54289. */
  54290. constructor(name: string);
  54291. /**
  54292. * Gets the current class name
  54293. * @returns the class name
  54294. */
  54295. getClassName(): string;
  54296. /**
  54297. * Gets the left operand input component
  54298. */
  54299. readonly left: NodeMaterialConnectionPoint;
  54300. /**
  54301. * Gets the right operand input component
  54302. */
  54303. readonly right: NodeMaterialConnectionPoint;
  54304. /**
  54305. * Gets the output component
  54306. */
  54307. readonly output: NodeMaterialConnectionPoint;
  54308. protected _buildBlock(state: NodeMaterialBuildState): this;
  54309. }
  54310. }
  54311. declare module BABYLON {
  54312. /**
  54313. * Block used to scale a vector by a float
  54314. */
  54315. export class ScaleBlock extends NodeMaterialBlock {
  54316. /**
  54317. * Creates a new ScaleBlock
  54318. * @param name defines the block name
  54319. */
  54320. constructor(name: string);
  54321. /**
  54322. * Gets the current class name
  54323. * @returns the class name
  54324. */
  54325. getClassName(): string;
  54326. /**
  54327. * Gets the input component
  54328. */
  54329. readonly input: NodeMaterialConnectionPoint;
  54330. /**
  54331. * Gets the factor input component
  54332. */
  54333. readonly factor: NodeMaterialConnectionPoint;
  54334. /**
  54335. * Gets the output component
  54336. */
  54337. readonly output: NodeMaterialConnectionPoint;
  54338. protected _buildBlock(state: NodeMaterialBuildState): this;
  54339. }
  54340. }
  54341. declare module BABYLON {
  54342. /**
  54343. * Block used to clamp a float
  54344. */
  54345. export class ClampBlock extends NodeMaterialBlock {
  54346. /** Gets or sets the minimum range */
  54347. minimum: number;
  54348. /** Gets or sets the maximum range */
  54349. maximum: number;
  54350. /**
  54351. * Creates a new ClampBlock
  54352. * @param name defines the block name
  54353. */
  54354. constructor(name: string);
  54355. /**
  54356. * Gets the current class name
  54357. * @returns the class name
  54358. */
  54359. getClassName(): string;
  54360. /**
  54361. * Gets the value input component
  54362. */
  54363. readonly value: NodeMaterialConnectionPoint;
  54364. /**
  54365. * Gets the output component
  54366. */
  54367. readonly output: NodeMaterialConnectionPoint;
  54368. protected _buildBlock(state: NodeMaterialBuildState): this;
  54369. protected _dumpPropertiesCode(): string;
  54370. serialize(): any;
  54371. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54372. }
  54373. }
  54374. declare module BABYLON {
  54375. /**
  54376. * Block used to apply a cross product between 2 vectors
  54377. */
  54378. export class CrossBlock extends NodeMaterialBlock {
  54379. /**
  54380. * Creates a new CrossBlock
  54381. * @param name defines the block name
  54382. */
  54383. constructor(name: string);
  54384. /**
  54385. * Gets the current class name
  54386. * @returns the class name
  54387. */
  54388. getClassName(): string;
  54389. /**
  54390. * Gets the left operand input component
  54391. */
  54392. readonly left: NodeMaterialConnectionPoint;
  54393. /**
  54394. * Gets the right operand input component
  54395. */
  54396. readonly right: NodeMaterialConnectionPoint;
  54397. /**
  54398. * Gets the output component
  54399. */
  54400. readonly output: NodeMaterialConnectionPoint;
  54401. protected _buildBlock(state: NodeMaterialBuildState): this;
  54402. }
  54403. }
  54404. declare module BABYLON {
  54405. /**
  54406. * Block used to apply a dot product between 2 vectors
  54407. */
  54408. export class DotBlock extends NodeMaterialBlock {
  54409. /**
  54410. * Creates a new DotBlock
  54411. * @param name defines the block name
  54412. */
  54413. constructor(name: string);
  54414. /**
  54415. * Gets the current class name
  54416. * @returns the class name
  54417. */
  54418. getClassName(): string;
  54419. /**
  54420. * Gets the left operand input component
  54421. */
  54422. readonly left: NodeMaterialConnectionPoint;
  54423. /**
  54424. * Gets the right operand input component
  54425. */
  54426. readonly right: NodeMaterialConnectionPoint;
  54427. /**
  54428. * Gets the output component
  54429. */
  54430. readonly output: NodeMaterialConnectionPoint;
  54431. protected _buildBlock(state: NodeMaterialBuildState): this;
  54432. }
  54433. }
  54434. declare module BABYLON {
  54435. /**
  54436. * Block used to remap a float from a range to a new one
  54437. */
  54438. export class RemapBlock extends NodeMaterialBlock {
  54439. /**
  54440. * Gets or sets the source range
  54441. */
  54442. sourceRange: Vector2;
  54443. /**
  54444. * Gets or sets the target range
  54445. */
  54446. targetRange: Vector2;
  54447. /**
  54448. * Creates a new RemapBlock
  54449. * @param name defines the block name
  54450. */
  54451. constructor(name: string);
  54452. /**
  54453. * Gets the current class name
  54454. * @returns the class name
  54455. */
  54456. getClassName(): string;
  54457. /**
  54458. * Gets the input component
  54459. */
  54460. readonly input: NodeMaterialConnectionPoint;
  54461. /**
  54462. * Gets the source min input component
  54463. */
  54464. readonly sourceMin: NodeMaterialConnectionPoint;
  54465. /**
  54466. * Gets the source max input component
  54467. */
  54468. readonly sourceMax: NodeMaterialConnectionPoint;
  54469. /**
  54470. * Gets the target min input component
  54471. */
  54472. readonly targetMin: NodeMaterialConnectionPoint;
  54473. /**
  54474. * Gets the target max input component
  54475. */
  54476. readonly targetMax: NodeMaterialConnectionPoint;
  54477. /**
  54478. * Gets the output component
  54479. */
  54480. readonly output: NodeMaterialConnectionPoint;
  54481. protected _buildBlock(state: NodeMaterialBuildState): this;
  54482. protected _dumpPropertiesCode(): string;
  54483. serialize(): any;
  54484. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54485. }
  54486. }
  54487. declare module BABYLON {
  54488. /**
  54489. * Block used to normalize a vector
  54490. */
  54491. export class NormalizeBlock extends NodeMaterialBlock {
  54492. /**
  54493. * Creates a new NormalizeBlock
  54494. * @param name defines the block name
  54495. */
  54496. constructor(name: string);
  54497. /**
  54498. * Gets the current class name
  54499. * @returns the class name
  54500. */
  54501. getClassName(): string;
  54502. /**
  54503. * Gets the input component
  54504. */
  54505. readonly input: NodeMaterialConnectionPoint;
  54506. /**
  54507. * Gets the output component
  54508. */
  54509. readonly output: NodeMaterialConnectionPoint;
  54510. protected _buildBlock(state: NodeMaterialBuildState): this;
  54511. }
  54512. }
  54513. declare module BABYLON {
  54514. /**
  54515. * Operations supported by the Trigonometry block
  54516. */
  54517. export enum TrigonometryBlockOperations {
  54518. /** Cos */
  54519. Cos = 0,
  54520. /** Sin */
  54521. Sin = 1,
  54522. /** Abs */
  54523. Abs = 2,
  54524. /** Exp */
  54525. Exp = 3,
  54526. /** Exp2 */
  54527. Exp2 = 4,
  54528. /** Round */
  54529. Round = 5,
  54530. /** Floor */
  54531. Floor = 6,
  54532. /** Ceiling */
  54533. Ceiling = 7,
  54534. /** Square root */
  54535. Sqrt = 8,
  54536. /** Log */
  54537. Log = 9,
  54538. /** Tangent */
  54539. Tan = 10,
  54540. /** Arc tangent */
  54541. ArcTan = 11,
  54542. /** Arc cosinus */
  54543. ArcCos = 12,
  54544. /** Arc sinus */
  54545. ArcSin = 13,
  54546. /** Fraction */
  54547. Fract = 14,
  54548. /** Sign */
  54549. Sign = 15,
  54550. /** To radians (from degrees) */
  54551. Radians = 16,
  54552. /** To degrees (from radians) */
  54553. Degrees = 17
  54554. }
  54555. /**
  54556. * Block used to apply trigonometry operation to floats
  54557. */
  54558. export class TrigonometryBlock extends NodeMaterialBlock {
  54559. /**
  54560. * Gets or sets the operation applied by the block
  54561. */
  54562. operation: TrigonometryBlockOperations;
  54563. /**
  54564. * Creates a new TrigonometryBlock
  54565. * @param name defines the block name
  54566. */
  54567. constructor(name: string);
  54568. /**
  54569. * Gets the current class name
  54570. * @returns the class name
  54571. */
  54572. getClassName(): string;
  54573. /**
  54574. * Gets the input component
  54575. */
  54576. readonly input: NodeMaterialConnectionPoint;
  54577. /**
  54578. * Gets the output component
  54579. */
  54580. readonly output: NodeMaterialConnectionPoint;
  54581. protected _buildBlock(state: NodeMaterialBuildState): this;
  54582. serialize(): any;
  54583. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54584. }
  54585. }
  54586. declare module BABYLON {
  54587. /**
  54588. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54589. */
  54590. export class ColorMergerBlock extends NodeMaterialBlock {
  54591. /**
  54592. * Create a new ColorMergerBlock
  54593. * @param name defines the block name
  54594. */
  54595. constructor(name: string);
  54596. /**
  54597. * Gets the current class name
  54598. * @returns the class name
  54599. */
  54600. getClassName(): string;
  54601. /**
  54602. * Gets the r component (input)
  54603. */
  54604. readonly r: NodeMaterialConnectionPoint;
  54605. /**
  54606. * Gets the g component (input)
  54607. */
  54608. readonly g: NodeMaterialConnectionPoint;
  54609. /**
  54610. * Gets the b component (input)
  54611. */
  54612. readonly b: NodeMaterialConnectionPoint;
  54613. /**
  54614. * Gets the a component (input)
  54615. */
  54616. readonly a: NodeMaterialConnectionPoint;
  54617. /**
  54618. * Gets the rgba component (output)
  54619. */
  54620. readonly rgba: NodeMaterialConnectionPoint;
  54621. /**
  54622. * Gets the rgb component (output)
  54623. */
  54624. readonly rgb: NodeMaterialConnectionPoint;
  54625. protected _buildBlock(state: NodeMaterialBuildState): this;
  54626. }
  54627. }
  54628. declare module BABYLON {
  54629. /**
  54630. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54631. */
  54632. export class VectorMergerBlock extends NodeMaterialBlock {
  54633. /**
  54634. * Create a new VectorMergerBlock
  54635. * @param name defines the block name
  54636. */
  54637. constructor(name: string);
  54638. /**
  54639. * Gets the current class name
  54640. * @returns the class name
  54641. */
  54642. getClassName(): string;
  54643. /**
  54644. * Gets the x component (input)
  54645. */
  54646. readonly x: NodeMaterialConnectionPoint;
  54647. /**
  54648. * Gets the y component (input)
  54649. */
  54650. readonly y: NodeMaterialConnectionPoint;
  54651. /**
  54652. * Gets the z component (input)
  54653. */
  54654. readonly z: NodeMaterialConnectionPoint;
  54655. /**
  54656. * Gets the w component (input)
  54657. */
  54658. readonly w: NodeMaterialConnectionPoint;
  54659. /**
  54660. * Gets the xyzw component (output)
  54661. */
  54662. readonly xyzw: NodeMaterialConnectionPoint;
  54663. /**
  54664. * Gets the xyz component (output)
  54665. */
  54666. readonly xyz: NodeMaterialConnectionPoint;
  54667. /**
  54668. * Gets the xy component (output)
  54669. */
  54670. readonly xy: NodeMaterialConnectionPoint;
  54671. protected _buildBlock(state: NodeMaterialBuildState): this;
  54672. }
  54673. }
  54674. declare module BABYLON {
  54675. /**
  54676. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54677. */
  54678. export class ColorSplitterBlock extends NodeMaterialBlock {
  54679. /**
  54680. * Create a new ColorSplitterBlock
  54681. * @param name defines the block name
  54682. */
  54683. constructor(name: string);
  54684. /**
  54685. * Gets the current class name
  54686. * @returns the class name
  54687. */
  54688. getClassName(): string;
  54689. /**
  54690. * Gets the rgba component (input)
  54691. */
  54692. readonly rgba: NodeMaterialConnectionPoint;
  54693. /**
  54694. * Gets the rgb component (input)
  54695. */
  54696. readonly rgbIn: NodeMaterialConnectionPoint;
  54697. /**
  54698. * Gets the rgb component (output)
  54699. */
  54700. readonly rgbOut: NodeMaterialConnectionPoint;
  54701. /**
  54702. * Gets the r component (output)
  54703. */
  54704. readonly r: NodeMaterialConnectionPoint;
  54705. /**
  54706. * Gets the g component (output)
  54707. */
  54708. readonly g: NodeMaterialConnectionPoint;
  54709. /**
  54710. * Gets the b component (output)
  54711. */
  54712. readonly b: NodeMaterialConnectionPoint;
  54713. /**
  54714. * Gets the a component (output)
  54715. */
  54716. readonly a: NodeMaterialConnectionPoint;
  54717. protected _inputRename(name: string): string;
  54718. protected _outputRename(name: string): string;
  54719. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54720. }
  54721. }
  54722. declare module BABYLON {
  54723. /**
  54724. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54725. */
  54726. export class VectorSplitterBlock extends NodeMaterialBlock {
  54727. /**
  54728. * Create a new VectorSplitterBlock
  54729. * @param name defines the block name
  54730. */
  54731. constructor(name: string);
  54732. /**
  54733. * Gets the current class name
  54734. * @returns the class name
  54735. */
  54736. getClassName(): string;
  54737. /**
  54738. * Gets the xyzw component (input)
  54739. */
  54740. readonly xyzw: NodeMaterialConnectionPoint;
  54741. /**
  54742. * Gets the xyz component (input)
  54743. */
  54744. readonly xyzIn: NodeMaterialConnectionPoint;
  54745. /**
  54746. * Gets the xy component (input)
  54747. */
  54748. readonly xyIn: NodeMaterialConnectionPoint;
  54749. /**
  54750. * Gets the xyz component (output)
  54751. */
  54752. readonly xyzOut: NodeMaterialConnectionPoint;
  54753. /**
  54754. * Gets the xy component (output)
  54755. */
  54756. readonly xyOut: NodeMaterialConnectionPoint;
  54757. /**
  54758. * Gets the x component (output)
  54759. */
  54760. readonly x: NodeMaterialConnectionPoint;
  54761. /**
  54762. * Gets the y component (output)
  54763. */
  54764. readonly y: NodeMaterialConnectionPoint;
  54765. /**
  54766. * Gets the z component (output)
  54767. */
  54768. readonly z: NodeMaterialConnectionPoint;
  54769. /**
  54770. * Gets the w component (output)
  54771. */
  54772. readonly w: NodeMaterialConnectionPoint;
  54773. protected _inputRename(name: string): string;
  54774. protected _outputRename(name: string): string;
  54775. protected _buildBlock(state: NodeMaterialBuildState): this;
  54776. }
  54777. }
  54778. declare module BABYLON {
  54779. /**
  54780. * Block used to lerp between 2 values
  54781. */
  54782. export class LerpBlock extends NodeMaterialBlock {
  54783. /**
  54784. * Creates a new LerpBlock
  54785. * @param name defines the block name
  54786. */
  54787. constructor(name: string);
  54788. /**
  54789. * Gets the current class name
  54790. * @returns the class name
  54791. */
  54792. getClassName(): string;
  54793. /**
  54794. * Gets the left operand input component
  54795. */
  54796. readonly left: NodeMaterialConnectionPoint;
  54797. /**
  54798. * Gets the right operand input component
  54799. */
  54800. readonly right: NodeMaterialConnectionPoint;
  54801. /**
  54802. * Gets the gradient operand input component
  54803. */
  54804. readonly gradient: NodeMaterialConnectionPoint;
  54805. /**
  54806. * Gets the output component
  54807. */
  54808. readonly output: NodeMaterialConnectionPoint;
  54809. protected _buildBlock(state: NodeMaterialBuildState): this;
  54810. }
  54811. }
  54812. declare module BABYLON {
  54813. /**
  54814. * Block used to divide 2 vectors
  54815. */
  54816. export class DivideBlock extends NodeMaterialBlock {
  54817. /**
  54818. * Creates a new DivideBlock
  54819. * @param name defines the block name
  54820. */
  54821. constructor(name: string);
  54822. /**
  54823. * Gets the current class name
  54824. * @returns the class name
  54825. */
  54826. getClassName(): string;
  54827. /**
  54828. * Gets the left operand input component
  54829. */
  54830. readonly left: NodeMaterialConnectionPoint;
  54831. /**
  54832. * Gets the right operand input component
  54833. */
  54834. readonly right: NodeMaterialConnectionPoint;
  54835. /**
  54836. * Gets the output component
  54837. */
  54838. readonly output: NodeMaterialConnectionPoint;
  54839. protected _buildBlock(state: NodeMaterialBuildState): this;
  54840. }
  54841. }
  54842. declare module BABYLON {
  54843. /**
  54844. * Block used to subtract 2 vectors
  54845. */
  54846. export class SubtractBlock extends NodeMaterialBlock {
  54847. /**
  54848. * Creates a new SubtractBlock
  54849. * @param name defines the block name
  54850. */
  54851. constructor(name: string);
  54852. /**
  54853. * Gets the current class name
  54854. * @returns the class name
  54855. */
  54856. getClassName(): string;
  54857. /**
  54858. * Gets the left operand input component
  54859. */
  54860. readonly left: NodeMaterialConnectionPoint;
  54861. /**
  54862. * Gets the right operand input component
  54863. */
  54864. readonly right: NodeMaterialConnectionPoint;
  54865. /**
  54866. * Gets the output component
  54867. */
  54868. readonly output: NodeMaterialConnectionPoint;
  54869. protected _buildBlock(state: NodeMaterialBuildState): this;
  54870. }
  54871. }
  54872. declare module BABYLON {
  54873. /**
  54874. * Block used to step a value
  54875. */
  54876. export class StepBlock extends NodeMaterialBlock {
  54877. /**
  54878. * Creates a new StepBlock
  54879. * @param name defines the block name
  54880. */
  54881. constructor(name: string);
  54882. /**
  54883. * Gets the current class name
  54884. * @returns the class name
  54885. */
  54886. getClassName(): string;
  54887. /**
  54888. * Gets the value operand input component
  54889. */
  54890. readonly value: NodeMaterialConnectionPoint;
  54891. /**
  54892. * Gets the edge operand input component
  54893. */
  54894. readonly edge: NodeMaterialConnectionPoint;
  54895. /**
  54896. * Gets the output component
  54897. */
  54898. readonly output: NodeMaterialConnectionPoint;
  54899. protected _buildBlock(state: NodeMaterialBuildState): this;
  54900. }
  54901. }
  54902. declare module BABYLON {
  54903. /**
  54904. * Block used to get the opposite (1 - x) of a value
  54905. */
  54906. export class OneMinusBlock extends NodeMaterialBlock {
  54907. /**
  54908. * Creates a new OneMinusBlock
  54909. * @param name defines the block name
  54910. */
  54911. constructor(name: string);
  54912. /**
  54913. * Gets the current class name
  54914. * @returns the class name
  54915. */
  54916. getClassName(): string;
  54917. /**
  54918. * Gets the input component
  54919. */
  54920. readonly input: NodeMaterialConnectionPoint;
  54921. /**
  54922. * Gets the output component
  54923. */
  54924. readonly output: NodeMaterialConnectionPoint;
  54925. protected _buildBlock(state: NodeMaterialBuildState): this;
  54926. }
  54927. }
  54928. declare module BABYLON {
  54929. /**
  54930. * Block used to get the view direction
  54931. */
  54932. export class ViewDirectionBlock extends NodeMaterialBlock {
  54933. /**
  54934. * Creates a new ViewDirectionBlock
  54935. * @param name defines the block name
  54936. */
  54937. constructor(name: string);
  54938. /**
  54939. * Gets the current class name
  54940. * @returns the class name
  54941. */
  54942. getClassName(): string;
  54943. /**
  54944. * Gets the world position component
  54945. */
  54946. readonly worldPosition: NodeMaterialConnectionPoint;
  54947. /**
  54948. * Gets the camera position component
  54949. */
  54950. readonly cameraPosition: NodeMaterialConnectionPoint;
  54951. /**
  54952. * Gets the output component
  54953. */
  54954. readonly output: NodeMaterialConnectionPoint;
  54955. autoConfigure(material: NodeMaterial): void;
  54956. protected _buildBlock(state: NodeMaterialBuildState): this;
  54957. }
  54958. }
  54959. declare module BABYLON {
  54960. /**
  54961. * Block used to compute fresnel value
  54962. */
  54963. export class FresnelBlock extends NodeMaterialBlock {
  54964. /**
  54965. * Create a new FresnelBlock
  54966. * @param name defines the block name
  54967. */
  54968. constructor(name: string);
  54969. /**
  54970. * Gets the current class name
  54971. * @returns the class name
  54972. */
  54973. getClassName(): string;
  54974. /**
  54975. * Gets the world normal input component
  54976. */
  54977. readonly worldNormal: NodeMaterialConnectionPoint;
  54978. /**
  54979. * Gets the view direction input component
  54980. */
  54981. readonly viewDirection: NodeMaterialConnectionPoint;
  54982. /**
  54983. * Gets the bias input component
  54984. */
  54985. readonly bias: NodeMaterialConnectionPoint;
  54986. /**
  54987. * Gets the camera (or eye) position component
  54988. */
  54989. readonly power: NodeMaterialConnectionPoint;
  54990. /**
  54991. * Gets the fresnel output component
  54992. */
  54993. readonly fresnel: NodeMaterialConnectionPoint;
  54994. autoConfigure(material: NodeMaterial): void;
  54995. protected _buildBlock(state: NodeMaterialBuildState): this;
  54996. }
  54997. }
  54998. declare module BABYLON {
  54999. /**
  55000. * Block used to get the max of 2 values
  55001. */
  55002. export class MaxBlock extends NodeMaterialBlock {
  55003. /**
  55004. * Creates a new MaxBlock
  55005. * @param name defines the block name
  55006. */
  55007. constructor(name: string);
  55008. /**
  55009. * Gets the current class name
  55010. * @returns the class name
  55011. */
  55012. getClassName(): string;
  55013. /**
  55014. * Gets the left operand input component
  55015. */
  55016. readonly left: NodeMaterialConnectionPoint;
  55017. /**
  55018. * Gets the right operand input component
  55019. */
  55020. readonly right: NodeMaterialConnectionPoint;
  55021. /**
  55022. * Gets the output component
  55023. */
  55024. readonly output: NodeMaterialConnectionPoint;
  55025. protected _buildBlock(state: NodeMaterialBuildState): this;
  55026. }
  55027. }
  55028. declare module BABYLON {
  55029. /**
  55030. * Block used to get the min of 2 values
  55031. */
  55032. export class MinBlock extends NodeMaterialBlock {
  55033. /**
  55034. * Creates a new MinBlock
  55035. * @param name defines the block name
  55036. */
  55037. constructor(name: string);
  55038. /**
  55039. * Gets the current class name
  55040. * @returns the class name
  55041. */
  55042. getClassName(): string;
  55043. /**
  55044. * Gets the left operand input component
  55045. */
  55046. readonly left: NodeMaterialConnectionPoint;
  55047. /**
  55048. * Gets the right operand input component
  55049. */
  55050. readonly right: NodeMaterialConnectionPoint;
  55051. /**
  55052. * Gets the output component
  55053. */
  55054. readonly output: NodeMaterialConnectionPoint;
  55055. protected _buildBlock(state: NodeMaterialBuildState): this;
  55056. }
  55057. }
  55058. declare module BABYLON {
  55059. /**
  55060. * Block used to get the distance between 2 values
  55061. */
  55062. export class DistanceBlock extends NodeMaterialBlock {
  55063. /**
  55064. * Creates a new DistanceBlock
  55065. * @param name defines the block name
  55066. */
  55067. constructor(name: string);
  55068. /**
  55069. * Gets the current class name
  55070. * @returns the class name
  55071. */
  55072. getClassName(): string;
  55073. /**
  55074. * Gets the left operand input component
  55075. */
  55076. readonly left: NodeMaterialConnectionPoint;
  55077. /**
  55078. * Gets the right operand input component
  55079. */
  55080. readonly right: NodeMaterialConnectionPoint;
  55081. /**
  55082. * Gets the output component
  55083. */
  55084. readonly output: NodeMaterialConnectionPoint;
  55085. protected _buildBlock(state: NodeMaterialBuildState): this;
  55086. }
  55087. }
  55088. declare module BABYLON {
  55089. /**
  55090. * Block used to get the length of a vector
  55091. */
  55092. export class LengthBlock extends NodeMaterialBlock {
  55093. /**
  55094. * Creates a new LengthBlock
  55095. * @param name defines the block name
  55096. */
  55097. constructor(name: string);
  55098. /**
  55099. * Gets the current class name
  55100. * @returns the class name
  55101. */
  55102. getClassName(): string;
  55103. /**
  55104. * Gets the value input component
  55105. */
  55106. readonly value: NodeMaterialConnectionPoint;
  55107. /**
  55108. * Gets the output component
  55109. */
  55110. readonly output: NodeMaterialConnectionPoint;
  55111. protected _buildBlock(state: NodeMaterialBuildState): this;
  55112. }
  55113. }
  55114. declare module BABYLON {
  55115. /**
  55116. * Block used to get negative version of a value (i.e. x * -1)
  55117. */
  55118. export class NegateBlock extends NodeMaterialBlock {
  55119. /**
  55120. * Creates a new NegateBlock
  55121. * @param name defines the block name
  55122. */
  55123. constructor(name: string);
  55124. /**
  55125. * Gets the current class name
  55126. * @returns the class name
  55127. */
  55128. getClassName(): string;
  55129. /**
  55130. * Gets the value input component
  55131. */
  55132. readonly value: NodeMaterialConnectionPoint;
  55133. /**
  55134. * Gets the output component
  55135. */
  55136. readonly output: NodeMaterialConnectionPoint;
  55137. protected _buildBlock(state: NodeMaterialBuildState): this;
  55138. }
  55139. }
  55140. declare module BABYLON {
  55141. /**
  55142. * Block used to get the value of the first parameter raised to the power of the second
  55143. */
  55144. export class PowBlock extends NodeMaterialBlock {
  55145. /**
  55146. * Creates a new PowBlock
  55147. * @param name defines the block name
  55148. */
  55149. constructor(name: string);
  55150. /**
  55151. * Gets the current class name
  55152. * @returns the class name
  55153. */
  55154. getClassName(): string;
  55155. /**
  55156. * Gets the value operand input component
  55157. */
  55158. readonly value: NodeMaterialConnectionPoint;
  55159. /**
  55160. * Gets the power operand input component
  55161. */
  55162. readonly power: NodeMaterialConnectionPoint;
  55163. /**
  55164. * Gets the output component
  55165. */
  55166. readonly output: NodeMaterialConnectionPoint;
  55167. protected _buildBlock(state: NodeMaterialBuildState): this;
  55168. }
  55169. }
  55170. declare module BABYLON {
  55171. /**
  55172. * Block used to get a random number
  55173. */
  55174. export class RandomNumberBlock extends NodeMaterialBlock {
  55175. /**
  55176. * Creates a new RandomNumberBlock
  55177. * @param name defines the block name
  55178. */
  55179. constructor(name: string);
  55180. /**
  55181. * Gets the current class name
  55182. * @returns the class name
  55183. */
  55184. getClassName(): string;
  55185. /**
  55186. * Gets the seed input component
  55187. */
  55188. readonly seed: NodeMaterialConnectionPoint;
  55189. /**
  55190. * Gets the output component
  55191. */
  55192. readonly output: NodeMaterialConnectionPoint;
  55193. protected _buildBlock(state: NodeMaterialBuildState): this;
  55194. }
  55195. }
  55196. declare module BABYLON {
  55197. /**
  55198. * Block used to compute arc tangent of 2 values
  55199. */
  55200. export class ArcTan2Block extends NodeMaterialBlock {
  55201. /**
  55202. * Creates a new ArcTan2Block
  55203. * @param name defines the block name
  55204. */
  55205. constructor(name: string);
  55206. /**
  55207. * Gets the current class name
  55208. * @returns the class name
  55209. */
  55210. getClassName(): string;
  55211. /**
  55212. * Gets the x operand input component
  55213. */
  55214. readonly x: NodeMaterialConnectionPoint;
  55215. /**
  55216. * Gets the y operand input component
  55217. */
  55218. readonly y: NodeMaterialConnectionPoint;
  55219. /**
  55220. * Gets the output component
  55221. */
  55222. readonly output: NodeMaterialConnectionPoint;
  55223. protected _buildBlock(state: NodeMaterialBuildState): this;
  55224. }
  55225. }
  55226. declare module BABYLON {
  55227. /**
  55228. * Block used to smooth step a value
  55229. */
  55230. export class SmoothStepBlock extends NodeMaterialBlock {
  55231. /**
  55232. * Creates a new SmoothStepBlock
  55233. * @param name defines the block name
  55234. */
  55235. constructor(name: string);
  55236. /**
  55237. * Gets the current class name
  55238. * @returns the class name
  55239. */
  55240. getClassName(): string;
  55241. /**
  55242. * Gets the value operand input component
  55243. */
  55244. readonly value: NodeMaterialConnectionPoint;
  55245. /**
  55246. * Gets the first edge operand input component
  55247. */
  55248. readonly edge0: NodeMaterialConnectionPoint;
  55249. /**
  55250. * Gets the second edge operand input component
  55251. */
  55252. readonly edge1: NodeMaterialConnectionPoint;
  55253. /**
  55254. * Gets the output component
  55255. */
  55256. readonly output: NodeMaterialConnectionPoint;
  55257. protected _buildBlock(state: NodeMaterialBuildState): this;
  55258. }
  55259. }
  55260. declare module BABYLON {
  55261. /**
  55262. * Block used to get the reciprocal (1 / x) of a value
  55263. */
  55264. export class ReciprocalBlock extends NodeMaterialBlock {
  55265. /**
  55266. * Creates a new ReciprocalBlock
  55267. * @param name defines the block name
  55268. */
  55269. constructor(name: string);
  55270. /**
  55271. * Gets the current class name
  55272. * @returns the class name
  55273. */
  55274. getClassName(): string;
  55275. /**
  55276. * Gets the input component
  55277. */
  55278. readonly input: NodeMaterialConnectionPoint;
  55279. /**
  55280. * Gets the output component
  55281. */
  55282. readonly output: NodeMaterialConnectionPoint;
  55283. protected _buildBlock(state: NodeMaterialBuildState): this;
  55284. }
  55285. }
  55286. declare module BABYLON {
  55287. /**
  55288. * Block used to replace a color by another one
  55289. */
  55290. export class ReplaceColorBlock extends NodeMaterialBlock {
  55291. /**
  55292. * Creates a new ReplaceColorBlock
  55293. * @param name defines the block name
  55294. */
  55295. constructor(name: string);
  55296. /**
  55297. * Gets the current class name
  55298. * @returns the class name
  55299. */
  55300. getClassName(): string;
  55301. /**
  55302. * Gets the value input component
  55303. */
  55304. readonly value: NodeMaterialConnectionPoint;
  55305. /**
  55306. * Gets the reference input component
  55307. */
  55308. readonly reference: NodeMaterialConnectionPoint;
  55309. /**
  55310. * Gets the distance input component
  55311. */
  55312. readonly distance: NodeMaterialConnectionPoint;
  55313. /**
  55314. * Gets the replacement input component
  55315. */
  55316. readonly replacement: NodeMaterialConnectionPoint;
  55317. /**
  55318. * Gets the output component
  55319. */
  55320. readonly output: NodeMaterialConnectionPoint;
  55321. protected _buildBlock(state: NodeMaterialBuildState): this;
  55322. }
  55323. }
  55324. declare module BABYLON {
  55325. /**
  55326. * Block used to posterize a value
  55327. * @see https://en.wikipedia.org/wiki/Posterization
  55328. */
  55329. export class PosterizeBlock extends NodeMaterialBlock {
  55330. /**
  55331. * Creates a new PosterizeBlock
  55332. * @param name defines the block name
  55333. */
  55334. constructor(name: string);
  55335. /**
  55336. * Gets the current class name
  55337. * @returns the class name
  55338. */
  55339. getClassName(): string;
  55340. /**
  55341. * Gets the value input component
  55342. */
  55343. readonly value: NodeMaterialConnectionPoint;
  55344. /**
  55345. * Gets the steps input component
  55346. */
  55347. readonly steps: NodeMaterialConnectionPoint;
  55348. /**
  55349. * Gets the output component
  55350. */
  55351. readonly output: NodeMaterialConnectionPoint;
  55352. protected _buildBlock(state: NodeMaterialBuildState): this;
  55353. }
  55354. }
  55355. declare module BABYLON {
  55356. /**
  55357. * Operations supported by the Wave block
  55358. */
  55359. export enum WaveBlockKind {
  55360. /** SawTooth */
  55361. SawTooth = 0,
  55362. /** Square */
  55363. Square = 1,
  55364. /** Triangle */
  55365. Triangle = 2
  55366. }
  55367. /**
  55368. * Block used to apply wave operation to floats
  55369. */
  55370. export class WaveBlock extends NodeMaterialBlock {
  55371. /**
  55372. * Gets or sets the kibnd of wave to be applied by the block
  55373. */
  55374. kind: WaveBlockKind;
  55375. /**
  55376. * Creates a new WaveBlock
  55377. * @param name defines the block name
  55378. */
  55379. constructor(name: string);
  55380. /**
  55381. * Gets the current class name
  55382. * @returns the class name
  55383. */
  55384. getClassName(): string;
  55385. /**
  55386. * Gets the input component
  55387. */
  55388. readonly input: NodeMaterialConnectionPoint;
  55389. /**
  55390. * Gets the output component
  55391. */
  55392. readonly output: NodeMaterialConnectionPoint;
  55393. protected _buildBlock(state: NodeMaterialBuildState): this;
  55394. serialize(): any;
  55395. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55396. }
  55397. }
  55398. declare module BABYLON {
  55399. /**
  55400. * Class used to store a color step for the GradientBlock
  55401. */
  55402. export class GradientBlockColorStep {
  55403. /**
  55404. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55405. */
  55406. step: number;
  55407. /**
  55408. * Gets or sets the color associated with this step
  55409. */
  55410. color: Color3;
  55411. /**
  55412. * Creates a new GradientBlockColorStep
  55413. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  55414. * @param color defines the color associated with this step
  55415. */
  55416. constructor(
  55417. /**
  55418. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55419. */
  55420. step: number,
  55421. /**
  55422. * Gets or sets the color associated with this step
  55423. */
  55424. color: Color3);
  55425. }
  55426. /**
  55427. * Block used to return a color from a gradient based on an input value between 0 and 1
  55428. */
  55429. export class GradientBlock extends NodeMaterialBlock {
  55430. /**
  55431. * Gets or sets the list of color steps
  55432. */
  55433. colorSteps: GradientBlockColorStep[];
  55434. /**
  55435. * Creates a new GradientBlock
  55436. * @param name defines the block name
  55437. */
  55438. constructor(name: string);
  55439. /**
  55440. * Gets the current class name
  55441. * @returns the class name
  55442. */
  55443. getClassName(): string;
  55444. /**
  55445. * Gets the gradient input component
  55446. */
  55447. readonly gradient: NodeMaterialConnectionPoint;
  55448. /**
  55449. * Gets the output component
  55450. */
  55451. readonly output: NodeMaterialConnectionPoint;
  55452. private _writeColorConstant;
  55453. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55454. serialize(): any;
  55455. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55456. protected _dumpPropertiesCode(): string;
  55457. }
  55458. }
  55459. declare module BABYLON {
  55460. /**
  55461. * Block used to normalize lerp between 2 values
  55462. */
  55463. export class NLerpBlock extends NodeMaterialBlock {
  55464. /**
  55465. * Creates a new NLerpBlock
  55466. * @param name defines the block name
  55467. */
  55468. constructor(name: string);
  55469. /**
  55470. * Gets the current class name
  55471. * @returns the class name
  55472. */
  55473. getClassName(): string;
  55474. /**
  55475. * Gets the left operand input component
  55476. */
  55477. readonly left: NodeMaterialConnectionPoint;
  55478. /**
  55479. * Gets the right operand input component
  55480. */
  55481. readonly right: NodeMaterialConnectionPoint;
  55482. /**
  55483. * Gets the gradient operand input component
  55484. */
  55485. readonly gradient: NodeMaterialConnectionPoint;
  55486. /**
  55487. * Gets the output component
  55488. */
  55489. readonly output: NodeMaterialConnectionPoint;
  55490. protected _buildBlock(state: NodeMaterialBuildState): this;
  55491. }
  55492. }
  55493. declare module BABYLON {
  55494. /**
  55495. * Effect Render Options
  55496. */
  55497. export interface IEffectRendererOptions {
  55498. /**
  55499. * Defines the vertices positions.
  55500. */
  55501. positions?: number[];
  55502. /**
  55503. * Defines the indices.
  55504. */
  55505. indices?: number[];
  55506. }
  55507. /**
  55508. * Helper class to render one or more effects
  55509. */
  55510. export class EffectRenderer {
  55511. private engine;
  55512. private static _DefaultOptions;
  55513. private _vertexBuffers;
  55514. private _indexBuffer;
  55515. private _ringBufferIndex;
  55516. private _ringScreenBuffer;
  55517. private _fullscreenViewport;
  55518. private _getNextFrameBuffer;
  55519. /**
  55520. * Creates an effect renderer
  55521. * @param engine the engine to use for rendering
  55522. * @param options defines the options of the effect renderer
  55523. */
  55524. constructor(engine: Engine, options?: IEffectRendererOptions);
  55525. /**
  55526. * Sets the current viewport in normalized coordinates 0-1
  55527. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55528. */
  55529. setViewport(viewport?: Viewport): void;
  55530. /**
  55531. * Binds the embedded attributes buffer to the effect.
  55532. * @param effect Defines the effect to bind the attributes for
  55533. */
  55534. bindBuffers(effect: Effect): void;
  55535. /**
  55536. * Sets the current effect wrapper to use during draw.
  55537. * The effect needs to be ready before calling this api.
  55538. * This also sets the default full screen position attribute.
  55539. * @param effectWrapper Defines the effect to draw with
  55540. */
  55541. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55542. /**
  55543. * Draws a full screen quad.
  55544. */
  55545. draw(): void;
  55546. /**
  55547. * renders one or more effects to a specified texture
  55548. * @param effectWrappers list of effects to renderer
  55549. * @param outputTexture texture to draw to, if null it will render to the screen
  55550. */
  55551. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55552. /**
  55553. * Disposes of the effect renderer
  55554. */
  55555. dispose(): void;
  55556. }
  55557. /**
  55558. * Options to create an EffectWrapper
  55559. */
  55560. interface EffectWrapperCreationOptions {
  55561. /**
  55562. * Engine to use to create the effect
  55563. */
  55564. engine: Engine;
  55565. /**
  55566. * Fragment shader for the effect
  55567. */
  55568. fragmentShader: string;
  55569. /**
  55570. * Vertex shader for the effect
  55571. */
  55572. vertexShader?: string;
  55573. /**
  55574. * Attributes to use in the shader
  55575. */
  55576. attributeNames?: Array<string>;
  55577. /**
  55578. * Uniforms to use in the shader
  55579. */
  55580. uniformNames?: Array<string>;
  55581. /**
  55582. * Texture sampler names to use in the shader
  55583. */
  55584. samplerNames?: Array<string>;
  55585. /**
  55586. * The friendly name of the effect displayed in Spector.
  55587. */
  55588. name?: string;
  55589. }
  55590. /**
  55591. * Wraps an effect to be used for rendering
  55592. */
  55593. export class EffectWrapper {
  55594. /**
  55595. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55596. */
  55597. onApplyObservable: Observable<{}>;
  55598. /**
  55599. * The underlying effect
  55600. */
  55601. effect: Effect;
  55602. /**
  55603. * Creates an effect to be renderer
  55604. * @param creationOptions options to create the effect
  55605. */
  55606. constructor(creationOptions: EffectWrapperCreationOptions);
  55607. /**
  55608. * Disposes of the effect wrapper
  55609. */
  55610. dispose(): void;
  55611. }
  55612. }
  55613. declare module BABYLON {
  55614. /**
  55615. * Helper class to push actions to a pool of workers.
  55616. */
  55617. export class WorkerPool implements IDisposable {
  55618. private _workerInfos;
  55619. private _pendingActions;
  55620. /**
  55621. * Constructor
  55622. * @param workers Array of workers to use for actions
  55623. */
  55624. constructor(workers: Array<Worker>);
  55625. /**
  55626. * Terminates all workers and clears any pending actions.
  55627. */
  55628. dispose(): void;
  55629. /**
  55630. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55631. * pended until a worker has completed its action.
  55632. * @param action The action to perform. Call onComplete when the action is complete.
  55633. */
  55634. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55635. private _execute;
  55636. }
  55637. }
  55638. declare module BABYLON {
  55639. /**
  55640. * Configuration for Draco compression
  55641. */
  55642. export interface IDracoCompressionConfiguration {
  55643. /**
  55644. * Configuration for the decoder.
  55645. */
  55646. decoder: {
  55647. /**
  55648. * The url to the WebAssembly module.
  55649. */
  55650. wasmUrl?: string;
  55651. /**
  55652. * The url to the WebAssembly binary.
  55653. */
  55654. wasmBinaryUrl?: string;
  55655. /**
  55656. * The url to the fallback JavaScript module.
  55657. */
  55658. fallbackUrl?: string;
  55659. };
  55660. }
  55661. /**
  55662. * Draco compression (https://google.github.io/draco/)
  55663. *
  55664. * This class wraps the Draco module.
  55665. *
  55666. * **Encoder**
  55667. *
  55668. * The encoder is not currently implemented.
  55669. *
  55670. * **Decoder**
  55671. *
  55672. * 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.
  55673. *
  55674. * To update the configuration, use the following code:
  55675. * ```javascript
  55676. * DracoCompression.Configuration = {
  55677. * decoder: {
  55678. * wasmUrl: "<url to the WebAssembly library>",
  55679. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55680. * fallbackUrl: "<url to the fallback JavaScript library>",
  55681. * }
  55682. * };
  55683. * ```
  55684. *
  55685. * 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.
  55686. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55687. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55688. *
  55689. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55690. * ```javascript
  55691. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55692. * ```
  55693. *
  55694. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55695. */
  55696. export class DracoCompression implements IDisposable {
  55697. private _workerPoolPromise?;
  55698. private _decoderModulePromise?;
  55699. /**
  55700. * The configuration. Defaults to the following urls:
  55701. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55702. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55703. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55704. */
  55705. static Configuration: IDracoCompressionConfiguration;
  55706. /**
  55707. * Returns true if the decoder configuration is available.
  55708. */
  55709. static readonly DecoderAvailable: boolean;
  55710. /**
  55711. * Default number of workers to create when creating the draco compression object.
  55712. */
  55713. static DefaultNumWorkers: number;
  55714. private static GetDefaultNumWorkers;
  55715. private static _Default;
  55716. /**
  55717. * Default instance for the draco compression object.
  55718. */
  55719. static readonly Default: DracoCompression;
  55720. /**
  55721. * Constructor
  55722. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55723. */
  55724. constructor(numWorkers?: number);
  55725. /**
  55726. * Stop all async operations and release resources.
  55727. */
  55728. dispose(): void;
  55729. /**
  55730. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55731. * @returns a promise that resolves when ready
  55732. */
  55733. whenReadyAsync(): Promise<void>;
  55734. /**
  55735. * Decode Draco compressed mesh data to vertex data.
  55736. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55737. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55738. * @returns A promise that resolves with the decoded vertex data
  55739. */
  55740. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55741. [kind: string]: number;
  55742. }): Promise<VertexData>;
  55743. }
  55744. }
  55745. declare module BABYLON {
  55746. /**
  55747. * Class for building Constructive Solid Geometry
  55748. */
  55749. export class CSG {
  55750. private polygons;
  55751. /**
  55752. * The world matrix
  55753. */
  55754. matrix: Matrix;
  55755. /**
  55756. * Stores the position
  55757. */
  55758. position: Vector3;
  55759. /**
  55760. * Stores the rotation
  55761. */
  55762. rotation: Vector3;
  55763. /**
  55764. * Stores the rotation quaternion
  55765. */
  55766. rotationQuaternion: Nullable<Quaternion>;
  55767. /**
  55768. * Stores the scaling vector
  55769. */
  55770. scaling: Vector3;
  55771. /**
  55772. * Convert the Mesh to CSG
  55773. * @param mesh The Mesh to convert to CSG
  55774. * @returns A new CSG from the Mesh
  55775. */
  55776. static FromMesh(mesh: Mesh): CSG;
  55777. /**
  55778. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55779. * @param polygons Polygons used to construct a CSG solid
  55780. */
  55781. private static FromPolygons;
  55782. /**
  55783. * Clones, or makes a deep copy, of the CSG
  55784. * @returns A new CSG
  55785. */
  55786. clone(): CSG;
  55787. /**
  55788. * Unions this CSG with another CSG
  55789. * @param csg The CSG to union against this CSG
  55790. * @returns The unioned CSG
  55791. */
  55792. union(csg: CSG): CSG;
  55793. /**
  55794. * Unions this CSG with another CSG in place
  55795. * @param csg The CSG to union against this CSG
  55796. */
  55797. unionInPlace(csg: CSG): void;
  55798. /**
  55799. * Subtracts this CSG with another CSG
  55800. * @param csg The CSG to subtract against this CSG
  55801. * @returns A new CSG
  55802. */
  55803. subtract(csg: CSG): CSG;
  55804. /**
  55805. * Subtracts this CSG with another CSG in place
  55806. * @param csg The CSG to subtact against this CSG
  55807. */
  55808. subtractInPlace(csg: CSG): void;
  55809. /**
  55810. * Intersect this CSG with another CSG
  55811. * @param csg The CSG to intersect against this CSG
  55812. * @returns A new CSG
  55813. */
  55814. intersect(csg: CSG): CSG;
  55815. /**
  55816. * Intersects this CSG with another CSG in place
  55817. * @param csg The CSG to intersect against this CSG
  55818. */
  55819. intersectInPlace(csg: CSG): void;
  55820. /**
  55821. * Return a new CSG solid with solid and empty space switched. This solid is
  55822. * not modified.
  55823. * @returns A new CSG solid with solid and empty space switched
  55824. */
  55825. inverse(): CSG;
  55826. /**
  55827. * Inverses the CSG in place
  55828. */
  55829. inverseInPlace(): void;
  55830. /**
  55831. * This is used to keep meshes transformations so they can be restored
  55832. * when we build back a Babylon Mesh
  55833. * NB : All CSG operations are performed in world coordinates
  55834. * @param csg The CSG to copy the transform attributes from
  55835. * @returns This CSG
  55836. */
  55837. copyTransformAttributes(csg: CSG): CSG;
  55838. /**
  55839. * Build Raw mesh from CSG
  55840. * Coordinates here are in world space
  55841. * @param name The name of the mesh geometry
  55842. * @param scene The Scene
  55843. * @param keepSubMeshes Specifies if the submeshes should be kept
  55844. * @returns A new Mesh
  55845. */
  55846. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55847. /**
  55848. * Build Mesh from CSG taking material and transforms into account
  55849. * @param name The name of the Mesh
  55850. * @param material The material of the Mesh
  55851. * @param scene The Scene
  55852. * @param keepSubMeshes Specifies if submeshes should be kept
  55853. * @returns The new Mesh
  55854. */
  55855. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55856. }
  55857. }
  55858. declare module BABYLON {
  55859. /**
  55860. * Class used to create a trail following a mesh
  55861. */
  55862. export class TrailMesh extends Mesh {
  55863. private _generator;
  55864. private _autoStart;
  55865. private _running;
  55866. private _diameter;
  55867. private _length;
  55868. private _sectionPolygonPointsCount;
  55869. private _sectionVectors;
  55870. private _sectionNormalVectors;
  55871. private _beforeRenderObserver;
  55872. /**
  55873. * @constructor
  55874. * @param name The value used by scene.getMeshByName() to do a lookup.
  55875. * @param generator The mesh to generate a trail.
  55876. * @param scene The scene to add this mesh to.
  55877. * @param diameter Diameter of trailing mesh. Default is 1.
  55878. * @param length Length of trailing mesh. Default is 60.
  55879. * @param autoStart Automatically start trailing mesh. Default true.
  55880. */
  55881. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55882. /**
  55883. * "TrailMesh"
  55884. * @returns "TrailMesh"
  55885. */
  55886. getClassName(): string;
  55887. private _createMesh;
  55888. /**
  55889. * Start trailing mesh.
  55890. */
  55891. start(): void;
  55892. /**
  55893. * Stop trailing mesh.
  55894. */
  55895. stop(): void;
  55896. /**
  55897. * Update trailing mesh geometry.
  55898. */
  55899. update(): void;
  55900. /**
  55901. * Returns a new TrailMesh object.
  55902. * @param name is a string, the name given to the new mesh
  55903. * @param newGenerator use new generator object for cloned trail mesh
  55904. * @returns a new mesh
  55905. */
  55906. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55907. /**
  55908. * Serializes this trail mesh
  55909. * @param serializationObject object to write serialization to
  55910. */
  55911. serialize(serializationObject: any): void;
  55912. /**
  55913. * Parses a serialized trail mesh
  55914. * @param parsedMesh the serialized mesh
  55915. * @param scene the scene to create the trail mesh in
  55916. * @returns the created trail mesh
  55917. */
  55918. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55919. }
  55920. }
  55921. declare module BABYLON {
  55922. /**
  55923. * Class containing static functions to help procedurally build meshes
  55924. */
  55925. export class TiledBoxBuilder {
  55926. /**
  55927. * Creates a box mesh
  55928. * 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)
  55929. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55931. * * 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
  55932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55933. * @param name defines the name of the mesh
  55934. * @param options defines the options used to create the mesh
  55935. * @param scene defines the hosting scene
  55936. * @returns the box mesh
  55937. */
  55938. static CreateTiledBox(name: string, options: {
  55939. pattern?: number;
  55940. width?: number;
  55941. height?: number;
  55942. depth?: number;
  55943. tileSize?: number;
  55944. tileWidth?: number;
  55945. tileHeight?: number;
  55946. alignHorizontal?: number;
  55947. alignVertical?: number;
  55948. faceUV?: Vector4[];
  55949. faceColors?: Color4[];
  55950. sideOrientation?: number;
  55951. updatable?: boolean;
  55952. }, scene?: Nullable<Scene>): Mesh;
  55953. }
  55954. }
  55955. declare module BABYLON {
  55956. /**
  55957. * Class containing static functions to help procedurally build meshes
  55958. */
  55959. export class TorusKnotBuilder {
  55960. /**
  55961. * Creates a torus knot mesh
  55962. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55963. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55964. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55965. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55967. * * 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
  55968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55969. * @param name defines the name of the mesh
  55970. * @param options defines the options used to create the mesh
  55971. * @param scene defines the hosting scene
  55972. * @returns the torus knot mesh
  55973. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55974. */
  55975. static CreateTorusKnot(name: string, options: {
  55976. radius?: number;
  55977. tube?: number;
  55978. radialSegments?: number;
  55979. tubularSegments?: number;
  55980. p?: number;
  55981. q?: number;
  55982. updatable?: boolean;
  55983. sideOrientation?: number;
  55984. frontUVs?: Vector4;
  55985. backUVs?: Vector4;
  55986. }, scene: any): Mesh;
  55987. }
  55988. }
  55989. declare module BABYLON {
  55990. /**
  55991. * Polygon
  55992. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55993. */
  55994. export class Polygon {
  55995. /**
  55996. * Creates a rectangle
  55997. * @param xmin bottom X coord
  55998. * @param ymin bottom Y coord
  55999. * @param xmax top X coord
  56000. * @param ymax top Y coord
  56001. * @returns points that make the resulting rectation
  56002. */
  56003. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56004. /**
  56005. * Creates a circle
  56006. * @param radius radius of circle
  56007. * @param cx scale in x
  56008. * @param cy scale in y
  56009. * @param numberOfSides number of sides that make up the circle
  56010. * @returns points that make the resulting circle
  56011. */
  56012. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56013. /**
  56014. * Creates a polygon from input string
  56015. * @param input Input polygon data
  56016. * @returns the parsed points
  56017. */
  56018. static Parse(input: string): Vector2[];
  56019. /**
  56020. * Starts building a polygon from x and y coordinates
  56021. * @param x x coordinate
  56022. * @param y y coordinate
  56023. * @returns the started path2
  56024. */
  56025. static StartingAt(x: number, y: number): Path2;
  56026. }
  56027. /**
  56028. * Builds a polygon
  56029. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56030. */
  56031. export class PolygonMeshBuilder {
  56032. private _points;
  56033. private _outlinepoints;
  56034. private _holes;
  56035. private _name;
  56036. private _scene;
  56037. private _epoints;
  56038. private _eholes;
  56039. private _addToepoint;
  56040. /**
  56041. * Babylon reference to the earcut plugin.
  56042. */
  56043. bjsEarcut: any;
  56044. /**
  56045. * Creates a PolygonMeshBuilder
  56046. * @param name name of the builder
  56047. * @param contours Path of the polygon
  56048. * @param scene scene to add to when creating the mesh
  56049. * @param earcutInjection can be used to inject your own earcut reference
  56050. */
  56051. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56052. /**
  56053. * Adds a whole within the polygon
  56054. * @param hole Array of points defining the hole
  56055. * @returns this
  56056. */
  56057. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56058. /**
  56059. * Creates the polygon
  56060. * @param updatable If the mesh should be updatable
  56061. * @param depth The depth of the mesh created
  56062. * @returns the created mesh
  56063. */
  56064. build(updatable?: boolean, depth?: number): Mesh;
  56065. /**
  56066. * Creates the polygon
  56067. * @param depth The depth of the mesh created
  56068. * @returns the created VertexData
  56069. */
  56070. buildVertexData(depth?: number): VertexData;
  56071. /**
  56072. * Adds a side to the polygon
  56073. * @param positions points that make the polygon
  56074. * @param normals normals of the polygon
  56075. * @param uvs uvs of the polygon
  56076. * @param indices indices of the polygon
  56077. * @param bounds bounds of the polygon
  56078. * @param points points of the polygon
  56079. * @param depth depth of the polygon
  56080. * @param flip flip of the polygon
  56081. */
  56082. private addSide;
  56083. }
  56084. }
  56085. declare module BABYLON {
  56086. /**
  56087. * Class containing static functions to help procedurally build meshes
  56088. */
  56089. export class PolygonBuilder {
  56090. /**
  56091. * Creates a polygon mesh
  56092. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56093. * * 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
  56094. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56096. * * 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)
  56097. * * Remember you can only change the shape positions, not their number when updating a polygon
  56098. * @param name defines the name of the mesh
  56099. * @param options defines the options used to create the mesh
  56100. * @param scene defines the hosting scene
  56101. * @param earcutInjection can be used to inject your own earcut reference
  56102. * @returns the polygon mesh
  56103. */
  56104. static CreatePolygon(name: string, options: {
  56105. shape: Vector3[];
  56106. holes?: Vector3[][];
  56107. depth?: number;
  56108. faceUV?: Vector4[];
  56109. faceColors?: Color4[];
  56110. updatable?: boolean;
  56111. sideOrientation?: number;
  56112. frontUVs?: Vector4;
  56113. backUVs?: Vector4;
  56114. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56115. /**
  56116. * Creates an extruded polygon mesh, with depth in the Y direction.
  56117. * * 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)
  56118. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56119. * @param name defines the name of the mesh
  56120. * @param options defines the options used to create the mesh
  56121. * @param scene defines the hosting scene
  56122. * @param earcutInjection can be used to inject your own earcut reference
  56123. * @returns the polygon mesh
  56124. */
  56125. static ExtrudePolygon(name: string, options: {
  56126. shape: Vector3[];
  56127. holes?: Vector3[][];
  56128. depth?: number;
  56129. faceUV?: Vector4[];
  56130. faceColors?: Color4[];
  56131. updatable?: boolean;
  56132. sideOrientation?: number;
  56133. frontUVs?: Vector4;
  56134. backUVs?: Vector4;
  56135. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56136. }
  56137. }
  56138. declare module BABYLON {
  56139. /**
  56140. * Class containing static functions to help procedurally build meshes
  56141. */
  56142. export class LatheBuilder {
  56143. /**
  56144. * Creates lathe mesh.
  56145. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56146. * * 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
  56147. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56148. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56149. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56150. * * 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
  56151. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56152. * * 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
  56153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56154. * * 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
  56155. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56157. * @param name defines the name of the mesh
  56158. * @param options defines the options used to create the mesh
  56159. * @param scene defines the hosting scene
  56160. * @returns the lathe mesh
  56161. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56162. */
  56163. static CreateLathe(name: string, options: {
  56164. shape: Vector3[];
  56165. radius?: number;
  56166. tessellation?: number;
  56167. clip?: number;
  56168. arc?: number;
  56169. closed?: boolean;
  56170. updatable?: boolean;
  56171. sideOrientation?: number;
  56172. frontUVs?: Vector4;
  56173. backUVs?: Vector4;
  56174. cap?: number;
  56175. invertUV?: boolean;
  56176. }, scene?: Nullable<Scene>): Mesh;
  56177. }
  56178. }
  56179. declare module BABYLON {
  56180. /**
  56181. * Class containing static functions to help procedurally build meshes
  56182. */
  56183. export class TiledPlaneBuilder {
  56184. /**
  56185. * Creates a tiled plane mesh
  56186. * * The parameter `pattern` will, depending on value, do nothing or
  56187. * * * flip (reflect about central vertical) alternate tiles across and up
  56188. * * * flip every tile on alternate rows
  56189. * * * rotate (180 degs) alternate tiles across and up
  56190. * * * rotate every tile on alternate rows
  56191. * * * flip and rotate alternate tiles across and up
  56192. * * * flip and rotate every tile on alternate rows
  56193. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56194. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56195. * * 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
  56196. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56197. * * 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)
  56198. * * 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)
  56199. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56200. * @param name defines the name of the mesh
  56201. * @param options defines the options used to create the mesh
  56202. * @param scene defines the hosting scene
  56203. * @returns the box mesh
  56204. */
  56205. static CreateTiledPlane(name: string, options: {
  56206. pattern?: number;
  56207. tileSize?: number;
  56208. tileWidth?: number;
  56209. tileHeight?: number;
  56210. size?: number;
  56211. width?: number;
  56212. height?: number;
  56213. alignHorizontal?: number;
  56214. alignVertical?: number;
  56215. sideOrientation?: number;
  56216. frontUVs?: Vector4;
  56217. backUVs?: Vector4;
  56218. updatable?: boolean;
  56219. }, scene?: Nullable<Scene>): Mesh;
  56220. }
  56221. }
  56222. declare module BABYLON {
  56223. /**
  56224. * Class containing static functions to help procedurally build meshes
  56225. */
  56226. export class TubeBuilder {
  56227. /**
  56228. * Creates a tube mesh.
  56229. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56230. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56231. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56232. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56233. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56234. * * 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)
  56235. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56236. * * 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
  56237. * * 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
  56238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56239. * * 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
  56240. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56242. * @param name defines the name of the mesh
  56243. * @param options defines the options used to create the mesh
  56244. * @param scene defines the hosting scene
  56245. * @returns the tube mesh
  56246. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56247. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56248. */
  56249. static CreateTube(name: string, options: {
  56250. path: Vector3[];
  56251. radius?: number;
  56252. tessellation?: number;
  56253. radiusFunction?: {
  56254. (i: number, distance: number): number;
  56255. };
  56256. cap?: number;
  56257. arc?: number;
  56258. updatable?: boolean;
  56259. sideOrientation?: number;
  56260. frontUVs?: Vector4;
  56261. backUVs?: Vector4;
  56262. instance?: Mesh;
  56263. invertUV?: boolean;
  56264. }, scene?: Nullable<Scene>): Mesh;
  56265. }
  56266. }
  56267. declare module BABYLON {
  56268. /**
  56269. * Class containing static functions to help procedurally build meshes
  56270. */
  56271. export class IcoSphereBuilder {
  56272. /**
  56273. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56274. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56275. * * 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`)
  56276. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56277. * * 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
  56278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56279. * * 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
  56280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56281. * @param name defines the name of the mesh
  56282. * @param options defines the options used to create the mesh
  56283. * @param scene defines the hosting scene
  56284. * @returns the icosahedron mesh
  56285. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56286. */
  56287. static CreateIcoSphere(name: string, options: {
  56288. radius?: number;
  56289. radiusX?: number;
  56290. radiusY?: number;
  56291. radiusZ?: number;
  56292. flat?: boolean;
  56293. subdivisions?: number;
  56294. sideOrientation?: number;
  56295. frontUVs?: Vector4;
  56296. backUVs?: Vector4;
  56297. updatable?: boolean;
  56298. }, scene?: Nullable<Scene>): Mesh;
  56299. }
  56300. }
  56301. declare module BABYLON {
  56302. /**
  56303. * Class containing static functions to help procedurally build meshes
  56304. */
  56305. export class DecalBuilder {
  56306. /**
  56307. * Creates a decal mesh.
  56308. * 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
  56309. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56310. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56311. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56312. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56313. * @param name defines the name of the mesh
  56314. * @param sourceMesh defines the mesh where the decal must be applied
  56315. * @param options defines the options used to create the mesh
  56316. * @param scene defines the hosting scene
  56317. * @returns the decal mesh
  56318. * @see https://doc.babylonjs.com/how_to/decals
  56319. */
  56320. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56321. position?: Vector3;
  56322. normal?: Vector3;
  56323. size?: Vector3;
  56324. angle?: number;
  56325. }): Mesh;
  56326. }
  56327. }
  56328. declare module BABYLON {
  56329. /**
  56330. * Class containing static functions to help procedurally build meshes
  56331. */
  56332. export class MeshBuilder {
  56333. /**
  56334. * Creates a box mesh
  56335. * * The parameter `size` sets the size (float) of each box side (default 1)
  56336. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56337. * * 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)
  56338. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56340. * * 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
  56341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56342. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56343. * @param name defines the name of the mesh
  56344. * @param options defines the options used to create the mesh
  56345. * @param scene defines the hosting scene
  56346. * @returns the box mesh
  56347. */
  56348. static CreateBox(name: string, options: {
  56349. size?: number;
  56350. width?: number;
  56351. height?: number;
  56352. depth?: number;
  56353. faceUV?: Vector4[];
  56354. faceColors?: Color4[];
  56355. sideOrientation?: number;
  56356. frontUVs?: Vector4;
  56357. backUVs?: Vector4;
  56358. updatable?: boolean;
  56359. }, scene?: Nullable<Scene>): Mesh;
  56360. /**
  56361. * Creates a tiled box mesh
  56362. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56364. * @param name defines the name of the mesh
  56365. * @param options defines the options used to create the mesh
  56366. * @param scene defines the hosting scene
  56367. * @returns the tiled box mesh
  56368. */
  56369. static CreateTiledBox(name: string, options: {
  56370. pattern?: number;
  56371. size?: number;
  56372. width?: number;
  56373. height?: number;
  56374. depth: number;
  56375. tileSize?: number;
  56376. tileWidth?: number;
  56377. tileHeight?: number;
  56378. faceUV?: Vector4[];
  56379. faceColors?: Color4[];
  56380. alignHorizontal?: number;
  56381. alignVertical?: number;
  56382. sideOrientation?: number;
  56383. updatable?: boolean;
  56384. }, scene?: Nullable<Scene>): Mesh;
  56385. /**
  56386. * Creates a sphere mesh
  56387. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56388. * * 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`)
  56389. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56390. * * 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
  56391. * * 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)
  56392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56393. * * 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
  56394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56395. * @param name defines the name of the mesh
  56396. * @param options defines the options used to create the mesh
  56397. * @param scene defines the hosting scene
  56398. * @returns the sphere mesh
  56399. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56400. */
  56401. static CreateSphere(name: string, options: {
  56402. segments?: number;
  56403. diameter?: number;
  56404. diameterX?: number;
  56405. diameterY?: number;
  56406. diameterZ?: number;
  56407. arc?: number;
  56408. slice?: number;
  56409. sideOrientation?: number;
  56410. frontUVs?: Vector4;
  56411. backUVs?: Vector4;
  56412. updatable?: boolean;
  56413. }, scene?: Nullable<Scene>): Mesh;
  56414. /**
  56415. * Creates a plane polygonal mesh. By default, this is a disc
  56416. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56417. * * 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
  56418. * * 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
  56419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56420. * * 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
  56421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56422. * @param name defines the name of the mesh
  56423. * @param options defines the options used to create the mesh
  56424. * @param scene defines the hosting scene
  56425. * @returns the plane polygonal mesh
  56426. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56427. */
  56428. static CreateDisc(name: string, options: {
  56429. radius?: number;
  56430. tessellation?: number;
  56431. arc?: number;
  56432. updatable?: boolean;
  56433. sideOrientation?: number;
  56434. frontUVs?: Vector4;
  56435. backUVs?: Vector4;
  56436. }, scene?: Nullable<Scene>): Mesh;
  56437. /**
  56438. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56439. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56440. * * 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`)
  56441. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56442. * * 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
  56443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56444. * * 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
  56445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56446. * @param name defines the name of the mesh
  56447. * @param options defines the options used to create the mesh
  56448. * @param scene defines the hosting scene
  56449. * @returns the icosahedron mesh
  56450. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56451. */
  56452. static CreateIcoSphere(name: string, options: {
  56453. radius?: number;
  56454. radiusX?: number;
  56455. radiusY?: number;
  56456. radiusZ?: number;
  56457. flat?: boolean;
  56458. subdivisions?: number;
  56459. sideOrientation?: number;
  56460. frontUVs?: Vector4;
  56461. backUVs?: Vector4;
  56462. updatable?: boolean;
  56463. }, scene?: Nullable<Scene>): Mesh;
  56464. /**
  56465. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56466. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56467. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56468. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56469. * * 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
  56470. * * 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
  56471. * * 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
  56472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56473. * * 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
  56474. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56475. * * 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
  56476. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56477. * * 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
  56478. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56480. * @param name defines the name of the mesh
  56481. * @param options defines the options used to create the mesh
  56482. * @param scene defines the hosting scene
  56483. * @returns the ribbon mesh
  56484. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56485. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56486. */
  56487. static CreateRibbon(name: string, options: {
  56488. pathArray: Vector3[][];
  56489. closeArray?: boolean;
  56490. closePath?: boolean;
  56491. offset?: number;
  56492. updatable?: boolean;
  56493. sideOrientation?: number;
  56494. frontUVs?: Vector4;
  56495. backUVs?: Vector4;
  56496. instance?: Mesh;
  56497. invertUV?: boolean;
  56498. uvs?: Vector2[];
  56499. colors?: Color4[];
  56500. }, scene?: Nullable<Scene>): Mesh;
  56501. /**
  56502. * Creates a cylinder or a cone mesh
  56503. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56504. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56505. * * 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.
  56506. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56507. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56508. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56509. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56510. * * 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).
  56511. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56512. * * 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).
  56513. * * 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
  56514. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56515. * * 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
  56516. * * 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.
  56517. * * If `enclose` is false, a ring surface is one element.
  56518. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56519. * * 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
  56520. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56521. * * 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
  56522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56523. * @param name defines the name of the mesh
  56524. * @param options defines the options used to create the mesh
  56525. * @param scene defines the hosting scene
  56526. * @returns the cylinder mesh
  56527. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56528. */
  56529. static CreateCylinder(name: string, options: {
  56530. height?: number;
  56531. diameterTop?: number;
  56532. diameterBottom?: number;
  56533. diameter?: number;
  56534. tessellation?: number;
  56535. subdivisions?: number;
  56536. arc?: number;
  56537. faceColors?: Color4[];
  56538. faceUV?: Vector4[];
  56539. updatable?: boolean;
  56540. hasRings?: boolean;
  56541. enclose?: boolean;
  56542. cap?: number;
  56543. sideOrientation?: number;
  56544. frontUVs?: Vector4;
  56545. backUVs?: Vector4;
  56546. }, scene?: Nullable<Scene>): Mesh;
  56547. /**
  56548. * Creates a torus mesh
  56549. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56550. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56551. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56553. * * 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
  56554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56555. * @param name defines the name of the mesh
  56556. * @param options defines the options used to create the mesh
  56557. * @param scene defines the hosting scene
  56558. * @returns the torus mesh
  56559. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56560. */
  56561. static CreateTorus(name: string, options: {
  56562. diameter?: number;
  56563. thickness?: number;
  56564. tessellation?: number;
  56565. updatable?: boolean;
  56566. sideOrientation?: number;
  56567. frontUVs?: Vector4;
  56568. backUVs?: Vector4;
  56569. }, scene?: Nullable<Scene>): Mesh;
  56570. /**
  56571. * Creates a torus knot mesh
  56572. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56573. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56574. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56575. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56577. * * 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
  56578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56579. * @param name defines the name of the mesh
  56580. * @param options defines the options used to create the mesh
  56581. * @param scene defines the hosting scene
  56582. * @returns the torus knot mesh
  56583. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56584. */
  56585. static CreateTorusKnot(name: string, options: {
  56586. radius?: number;
  56587. tube?: number;
  56588. radialSegments?: number;
  56589. tubularSegments?: number;
  56590. p?: number;
  56591. q?: number;
  56592. updatable?: boolean;
  56593. sideOrientation?: number;
  56594. frontUVs?: Vector4;
  56595. backUVs?: Vector4;
  56596. }, scene?: Nullable<Scene>): Mesh;
  56597. /**
  56598. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56599. * * 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
  56600. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56601. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56602. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56603. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56604. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56605. * * 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
  56606. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56608. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56609. * @param name defines the name of the new line system
  56610. * @param options defines the options used to create the line system
  56611. * @param scene defines the hosting scene
  56612. * @returns a new line system mesh
  56613. */
  56614. static CreateLineSystem(name: string, options: {
  56615. lines: Vector3[][];
  56616. updatable?: boolean;
  56617. instance?: Nullable<LinesMesh>;
  56618. colors?: Nullable<Color4[][]>;
  56619. useVertexAlpha?: boolean;
  56620. }, scene: Nullable<Scene>): LinesMesh;
  56621. /**
  56622. * Creates a line mesh
  56623. * 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
  56624. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56625. * * The parameter `points` is an array successive Vector3
  56626. * * 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
  56627. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56628. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56629. * * When updating an instance, remember that only point positions can change, not the number of points
  56630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56631. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56632. * @param name defines the name of the new line system
  56633. * @param options defines the options used to create the line system
  56634. * @param scene defines the hosting scene
  56635. * @returns a new line mesh
  56636. */
  56637. static CreateLines(name: string, options: {
  56638. points: Vector3[];
  56639. updatable?: boolean;
  56640. instance?: Nullable<LinesMesh>;
  56641. colors?: Color4[];
  56642. useVertexAlpha?: boolean;
  56643. }, scene?: Nullable<Scene>): LinesMesh;
  56644. /**
  56645. * Creates a dashed line mesh
  56646. * * 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
  56647. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56648. * * The parameter `points` is an array successive Vector3
  56649. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56650. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56651. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56652. * * 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
  56653. * * When updating an instance, remember that only point positions can change, not the number of points
  56654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56655. * @param name defines the name of the mesh
  56656. * @param options defines the options used to create the mesh
  56657. * @param scene defines the hosting scene
  56658. * @returns the dashed line mesh
  56659. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56660. */
  56661. static CreateDashedLines(name: string, options: {
  56662. points: Vector3[];
  56663. dashSize?: number;
  56664. gapSize?: number;
  56665. dashNb?: number;
  56666. updatable?: boolean;
  56667. instance?: LinesMesh;
  56668. }, scene?: Nullable<Scene>): LinesMesh;
  56669. /**
  56670. * 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.
  56671. * * 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.
  56672. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56673. * * 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.
  56674. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56675. * * 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
  56676. * * 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
  56677. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56679. * * 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
  56680. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56682. * @param name defines the name of the mesh
  56683. * @param options defines the options used to create the mesh
  56684. * @param scene defines the hosting scene
  56685. * @returns the extruded shape mesh
  56686. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56687. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56688. */
  56689. static ExtrudeShape(name: string, options: {
  56690. shape: Vector3[];
  56691. path: Vector3[];
  56692. scale?: number;
  56693. rotation?: number;
  56694. cap?: number;
  56695. updatable?: boolean;
  56696. sideOrientation?: number;
  56697. frontUVs?: Vector4;
  56698. backUVs?: Vector4;
  56699. instance?: Mesh;
  56700. invertUV?: boolean;
  56701. }, scene?: Nullable<Scene>): Mesh;
  56702. /**
  56703. * Creates an custom extruded shape mesh.
  56704. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56705. * * 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.
  56706. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56707. * * 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
  56708. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56709. * * 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
  56710. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56711. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56712. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56713. * * 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
  56714. * * 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
  56715. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56717. * * 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
  56718. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56720. * @param name defines the name of the mesh
  56721. * @param options defines the options used to create the mesh
  56722. * @param scene defines the hosting scene
  56723. * @returns the custom extruded shape mesh
  56724. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56725. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56726. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56727. */
  56728. static ExtrudeShapeCustom(name: string, options: {
  56729. shape: Vector3[];
  56730. path: Vector3[];
  56731. scaleFunction?: any;
  56732. rotationFunction?: any;
  56733. ribbonCloseArray?: boolean;
  56734. ribbonClosePath?: boolean;
  56735. cap?: number;
  56736. updatable?: boolean;
  56737. sideOrientation?: number;
  56738. frontUVs?: Vector4;
  56739. backUVs?: Vector4;
  56740. instance?: Mesh;
  56741. invertUV?: boolean;
  56742. }, scene?: Nullable<Scene>): Mesh;
  56743. /**
  56744. * Creates lathe mesh.
  56745. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56746. * * 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
  56747. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56748. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56749. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56750. * * 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
  56751. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56752. * * 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
  56753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56754. * * 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
  56755. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56757. * @param name defines the name of the mesh
  56758. * @param options defines the options used to create the mesh
  56759. * @param scene defines the hosting scene
  56760. * @returns the lathe mesh
  56761. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56762. */
  56763. static CreateLathe(name: string, options: {
  56764. shape: Vector3[];
  56765. radius?: number;
  56766. tessellation?: number;
  56767. clip?: number;
  56768. arc?: number;
  56769. closed?: boolean;
  56770. updatable?: boolean;
  56771. sideOrientation?: number;
  56772. frontUVs?: Vector4;
  56773. backUVs?: Vector4;
  56774. cap?: number;
  56775. invertUV?: boolean;
  56776. }, scene?: Nullable<Scene>): Mesh;
  56777. /**
  56778. * Creates a tiled plane mesh
  56779. * * You can set a limited pattern arrangement with the tiles
  56780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56781. * * 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
  56782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56783. * @param name defines the name of the mesh
  56784. * @param options defines the options used to create the mesh
  56785. * @param scene defines the hosting scene
  56786. * @returns the plane mesh
  56787. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56788. */
  56789. static CreateTiledPlane(name: string, options: {
  56790. pattern?: number;
  56791. tileSize?: number;
  56792. tileWidth?: number;
  56793. tileHeight?: number;
  56794. size?: number;
  56795. width?: number;
  56796. height?: number;
  56797. alignHorizontal?: number;
  56798. alignVertical?: number;
  56799. sideOrientation?: number;
  56800. frontUVs?: Vector4;
  56801. backUVs?: Vector4;
  56802. updatable?: boolean;
  56803. }, scene?: Nullable<Scene>): Mesh;
  56804. /**
  56805. * Creates a plane mesh
  56806. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56807. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56808. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56810. * * 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
  56811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56812. * @param name defines the name of the mesh
  56813. * @param options defines the options used to create the mesh
  56814. * @param scene defines the hosting scene
  56815. * @returns the plane mesh
  56816. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56817. */
  56818. static CreatePlane(name: string, options: {
  56819. size?: number;
  56820. width?: number;
  56821. height?: number;
  56822. sideOrientation?: number;
  56823. frontUVs?: Vector4;
  56824. backUVs?: Vector4;
  56825. updatable?: boolean;
  56826. sourcePlane?: Plane;
  56827. }, scene?: Nullable<Scene>): Mesh;
  56828. /**
  56829. * Creates a ground mesh
  56830. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56831. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56833. * @param name defines the name of the mesh
  56834. * @param options defines the options used to create the mesh
  56835. * @param scene defines the hosting scene
  56836. * @returns the ground mesh
  56837. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56838. */
  56839. static CreateGround(name: string, options: {
  56840. width?: number;
  56841. height?: number;
  56842. subdivisions?: number;
  56843. subdivisionsX?: number;
  56844. subdivisionsY?: number;
  56845. updatable?: boolean;
  56846. }, scene?: Nullable<Scene>): Mesh;
  56847. /**
  56848. * Creates a tiled ground mesh
  56849. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56850. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56851. * * 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
  56852. * * 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
  56853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56854. * @param name defines the name of the mesh
  56855. * @param options defines the options used to create the mesh
  56856. * @param scene defines the hosting scene
  56857. * @returns the tiled ground mesh
  56858. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56859. */
  56860. static CreateTiledGround(name: string, options: {
  56861. xmin: number;
  56862. zmin: number;
  56863. xmax: number;
  56864. zmax: number;
  56865. subdivisions?: {
  56866. w: number;
  56867. h: number;
  56868. };
  56869. precision?: {
  56870. w: number;
  56871. h: number;
  56872. };
  56873. updatable?: boolean;
  56874. }, scene?: Nullable<Scene>): Mesh;
  56875. /**
  56876. * Creates a ground mesh from a height map
  56877. * * The parameter `url` sets the URL of the height map image resource.
  56878. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56879. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56880. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56881. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56882. * * 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.
  56883. * * 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).
  56884. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56886. * @param name defines the name of the mesh
  56887. * @param url defines the url to the height map
  56888. * @param options defines the options used to create the mesh
  56889. * @param scene defines the hosting scene
  56890. * @returns the ground mesh
  56891. * @see https://doc.babylonjs.com/babylon101/height_map
  56892. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56893. */
  56894. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56895. width?: number;
  56896. height?: number;
  56897. subdivisions?: number;
  56898. minHeight?: number;
  56899. maxHeight?: number;
  56900. colorFilter?: Color3;
  56901. alphaFilter?: number;
  56902. updatable?: boolean;
  56903. onReady?: (mesh: GroundMesh) => void;
  56904. }, scene?: Nullable<Scene>): GroundMesh;
  56905. /**
  56906. * Creates a polygon mesh
  56907. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56908. * * 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
  56909. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56911. * * 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)
  56912. * * Remember you can only change the shape positions, not their number when updating a polygon
  56913. * @param name defines the name of the mesh
  56914. * @param options defines the options used to create the mesh
  56915. * @param scene defines the hosting scene
  56916. * @param earcutInjection can be used to inject your own earcut reference
  56917. * @returns the polygon mesh
  56918. */
  56919. static CreatePolygon(name: string, options: {
  56920. shape: Vector3[];
  56921. holes?: Vector3[][];
  56922. depth?: number;
  56923. faceUV?: Vector4[];
  56924. faceColors?: Color4[];
  56925. updatable?: boolean;
  56926. sideOrientation?: number;
  56927. frontUVs?: Vector4;
  56928. backUVs?: Vector4;
  56929. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56930. /**
  56931. * Creates an extruded polygon mesh, with depth in the Y direction.
  56932. * * 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)
  56933. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56934. * @param name defines the name of the mesh
  56935. * @param options defines the options used to create the mesh
  56936. * @param scene defines the hosting scene
  56937. * @param earcutInjection can be used to inject your own earcut reference
  56938. * @returns the polygon mesh
  56939. */
  56940. static ExtrudePolygon(name: string, options: {
  56941. shape: Vector3[];
  56942. holes?: Vector3[][];
  56943. depth?: number;
  56944. faceUV?: Vector4[];
  56945. faceColors?: Color4[];
  56946. updatable?: boolean;
  56947. sideOrientation?: number;
  56948. frontUVs?: Vector4;
  56949. backUVs?: Vector4;
  56950. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56951. /**
  56952. * Creates a tube mesh.
  56953. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56954. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56955. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56956. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56957. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56958. * * 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)
  56959. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56960. * * 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
  56961. * * 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
  56962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56963. * * 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
  56964. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56966. * @param name defines the name of the mesh
  56967. * @param options defines the options used to create the mesh
  56968. * @param scene defines the hosting scene
  56969. * @returns the tube mesh
  56970. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56971. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56972. */
  56973. static CreateTube(name: string, options: {
  56974. path: Vector3[];
  56975. radius?: number;
  56976. tessellation?: number;
  56977. radiusFunction?: {
  56978. (i: number, distance: number): number;
  56979. };
  56980. cap?: number;
  56981. arc?: number;
  56982. updatable?: boolean;
  56983. sideOrientation?: number;
  56984. frontUVs?: Vector4;
  56985. backUVs?: Vector4;
  56986. instance?: Mesh;
  56987. invertUV?: boolean;
  56988. }, scene?: Nullable<Scene>): Mesh;
  56989. /**
  56990. * Creates a polyhedron mesh
  56991. * * 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
  56992. * * The parameter `size` (positive float, default 1) sets the polygon size
  56993. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56994. * * 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`
  56995. * * 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
  56996. * * 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)`)
  56997. * * 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
  56998. * * 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
  56999. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57000. * * 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
  57001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57002. * @param name defines the name of the mesh
  57003. * @param options defines the options used to create the mesh
  57004. * @param scene defines the hosting scene
  57005. * @returns the polyhedron mesh
  57006. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57007. */
  57008. static CreatePolyhedron(name: string, options: {
  57009. type?: number;
  57010. size?: number;
  57011. sizeX?: number;
  57012. sizeY?: number;
  57013. sizeZ?: number;
  57014. custom?: any;
  57015. faceUV?: Vector4[];
  57016. faceColors?: Color4[];
  57017. flat?: boolean;
  57018. updatable?: boolean;
  57019. sideOrientation?: number;
  57020. frontUVs?: Vector4;
  57021. backUVs?: Vector4;
  57022. }, scene?: Nullable<Scene>): Mesh;
  57023. /**
  57024. * Creates a decal mesh.
  57025. * 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
  57026. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57027. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57028. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57029. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57030. * @param name defines the name of the mesh
  57031. * @param sourceMesh defines the mesh where the decal must be applied
  57032. * @param options defines the options used to create the mesh
  57033. * @param scene defines the hosting scene
  57034. * @returns the decal mesh
  57035. * @see https://doc.babylonjs.com/how_to/decals
  57036. */
  57037. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57038. position?: Vector3;
  57039. normal?: Vector3;
  57040. size?: Vector3;
  57041. angle?: number;
  57042. }): Mesh;
  57043. }
  57044. }
  57045. declare module BABYLON {
  57046. /**
  57047. * A simplifier interface for future simplification implementations
  57048. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57049. */
  57050. export interface ISimplifier {
  57051. /**
  57052. * Simplification of a given mesh according to the given settings.
  57053. * Since this requires computation, it is assumed that the function runs async.
  57054. * @param settings The settings of the simplification, including quality and distance
  57055. * @param successCallback A callback that will be called after the mesh was simplified.
  57056. * @param errorCallback in case of an error, this callback will be called. optional.
  57057. */
  57058. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57059. }
  57060. /**
  57061. * Expected simplification settings.
  57062. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57063. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57064. */
  57065. export interface ISimplificationSettings {
  57066. /**
  57067. * Gets or sets the expected quality
  57068. */
  57069. quality: number;
  57070. /**
  57071. * Gets or sets the distance when this optimized version should be used
  57072. */
  57073. distance: number;
  57074. /**
  57075. * Gets an already optimized mesh
  57076. */
  57077. optimizeMesh?: boolean;
  57078. }
  57079. /**
  57080. * Class used to specify simplification options
  57081. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57082. */
  57083. export class SimplificationSettings implements ISimplificationSettings {
  57084. /** expected quality */
  57085. quality: number;
  57086. /** distance when this optimized version should be used */
  57087. distance: number;
  57088. /** already optimized mesh */
  57089. optimizeMesh?: boolean | undefined;
  57090. /**
  57091. * Creates a SimplificationSettings
  57092. * @param quality expected quality
  57093. * @param distance distance when this optimized version should be used
  57094. * @param optimizeMesh already optimized mesh
  57095. */
  57096. constructor(
  57097. /** expected quality */
  57098. quality: number,
  57099. /** distance when this optimized version should be used */
  57100. distance: number,
  57101. /** already optimized mesh */
  57102. optimizeMesh?: boolean | undefined);
  57103. }
  57104. /**
  57105. * Interface used to define a simplification task
  57106. */
  57107. export interface ISimplificationTask {
  57108. /**
  57109. * Array of settings
  57110. */
  57111. settings: Array<ISimplificationSettings>;
  57112. /**
  57113. * Simplification type
  57114. */
  57115. simplificationType: SimplificationType;
  57116. /**
  57117. * Mesh to simplify
  57118. */
  57119. mesh: Mesh;
  57120. /**
  57121. * Callback called on success
  57122. */
  57123. successCallback?: () => void;
  57124. /**
  57125. * Defines if parallel processing can be used
  57126. */
  57127. parallelProcessing: boolean;
  57128. }
  57129. /**
  57130. * Queue used to order the simplification tasks
  57131. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57132. */
  57133. export class SimplificationQueue {
  57134. private _simplificationArray;
  57135. /**
  57136. * Gets a boolean indicating that the process is still running
  57137. */
  57138. running: boolean;
  57139. /**
  57140. * Creates a new queue
  57141. */
  57142. constructor();
  57143. /**
  57144. * Adds a new simplification task
  57145. * @param task defines a task to add
  57146. */
  57147. addTask(task: ISimplificationTask): void;
  57148. /**
  57149. * Execute next task
  57150. */
  57151. executeNext(): void;
  57152. /**
  57153. * Execute a simplification task
  57154. * @param task defines the task to run
  57155. */
  57156. runSimplification(task: ISimplificationTask): void;
  57157. private getSimplifier;
  57158. }
  57159. /**
  57160. * The implemented types of simplification
  57161. * At the moment only Quadratic Error Decimation is implemented
  57162. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57163. */
  57164. export enum SimplificationType {
  57165. /** Quadratic error decimation */
  57166. QUADRATIC = 0
  57167. }
  57168. }
  57169. declare module BABYLON {
  57170. interface Scene {
  57171. /** @hidden (Backing field) */
  57172. _simplificationQueue: SimplificationQueue;
  57173. /**
  57174. * Gets or sets the simplification queue attached to the scene
  57175. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57176. */
  57177. simplificationQueue: SimplificationQueue;
  57178. }
  57179. interface Mesh {
  57180. /**
  57181. * Simplify the mesh according to the given array of settings.
  57182. * Function will return immediately and will simplify async
  57183. * @param settings a collection of simplification settings
  57184. * @param parallelProcessing should all levels calculate parallel or one after the other
  57185. * @param simplificationType the type of simplification to run
  57186. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57187. * @returns the current mesh
  57188. */
  57189. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57190. }
  57191. /**
  57192. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57193. * created in a scene
  57194. */
  57195. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57196. /**
  57197. * The component name helpfull to identify the component in the list of scene components.
  57198. */
  57199. readonly name: string;
  57200. /**
  57201. * The scene the component belongs to.
  57202. */
  57203. scene: Scene;
  57204. /**
  57205. * Creates a new instance of the component for the given scene
  57206. * @param scene Defines the scene to register the component in
  57207. */
  57208. constructor(scene: Scene);
  57209. /**
  57210. * Registers the component in a given scene
  57211. */
  57212. register(): void;
  57213. /**
  57214. * Rebuilds the elements related to this component in case of
  57215. * context lost for instance.
  57216. */
  57217. rebuild(): void;
  57218. /**
  57219. * Disposes the component and the associated ressources
  57220. */
  57221. dispose(): void;
  57222. private _beforeCameraUpdate;
  57223. }
  57224. }
  57225. declare module BABYLON {
  57226. /**
  57227. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57228. */
  57229. export interface INavigationEnginePlugin {
  57230. /**
  57231. * plugin name
  57232. */
  57233. name: string;
  57234. /**
  57235. * Creates a navigation mesh
  57236. * @param meshes array of all the geometry used to compute the navigatio mesh
  57237. * @param parameters bunch of parameters used to filter geometry
  57238. */
  57239. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57240. /**
  57241. * Create a navigation mesh debug mesh
  57242. * @param scene is where the mesh will be added
  57243. * @returns debug display mesh
  57244. */
  57245. createDebugNavMesh(scene: Scene): Mesh;
  57246. /**
  57247. * Get a navigation mesh constrained position, closest to the parameter position
  57248. * @param position world position
  57249. * @returns the closest point to position constrained by the navigation mesh
  57250. */
  57251. getClosestPoint(position: Vector3): Vector3;
  57252. /**
  57253. * Get a navigation mesh constrained position, within a particular radius
  57254. * @param position world position
  57255. * @param maxRadius the maximum distance to the constrained world position
  57256. * @returns the closest point to position constrained by the navigation mesh
  57257. */
  57258. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57259. /**
  57260. * Compute the final position from a segment made of destination-position
  57261. * @param position world position
  57262. * @param destination world position
  57263. * @returns the resulting point along the navmesh
  57264. */
  57265. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57266. /**
  57267. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57268. * @param start world position
  57269. * @param end world position
  57270. * @returns array containing world position composing the path
  57271. */
  57272. computePath(start: Vector3, end: Vector3): Vector3[];
  57273. /**
  57274. * If this plugin is supported
  57275. * @returns true if plugin is supported
  57276. */
  57277. isSupported(): boolean;
  57278. /**
  57279. * Create a new Crowd so you can add agents
  57280. * @param maxAgents the maximum agent count in the crowd
  57281. * @param maxAgentRadius the maximum radius an agent can have
  57282. * @param scene to attach the crowd to
  57283. * @returns the crowd you can add agents to
  57284. */
  57285. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57286. /**
  57287. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57288. * The queries will try to find a solution within those bounds
  57289. * default is (1,1,1)
  57290. * @param extent x,y,z value that define the extent around the queries point of reference
  57291. */
  57292. setDefaultQueryExtent(extent: Vector3): void;
  57293. /**
  57294. * Get the Bounding box extent specified by setDefaultQueryExtent
  57295. * @returns the box extent values
  57296. */
  57297. getDefaultQueryExtent(): Vector3;
  57298. /**
  57299. * Release all resources
  57300. */
  57301. dispose(): void;
  57302. }
  57303. /**
  57304. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57305. */
  57306. export interface ICrowd {
  57307. /**
  57308. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57309. * You can attach anything to that node. The node position is updated in the scene update tick.
  57310. * @param pos world position that will be constrained by the navigation mesh
  57311. * @param parameters agent parameters
  57312. * @param transform hooked to the agent that will be update by the scene
  57313. * @returns agent index
  57314. */
  57315. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57316. /**
  57317. * Returns the agent position in world space
  57318. * @param index agent index returned by addAgent
  57319. * @returns world space position
  57320. */
  57321. getAgentPosition(index: number): Vector3;
  57322. /**
  57323. * Gets the agent velocity in world space
  57324. * @param index agent index returned by addAgent
  57325. * @returns world space velocity
  57326. */
  57327. getAgentVelocity(index: number): Vector3;
  57328. /**
  57329. * remove a particular agent previously created
  57330. * @param index agent index returned by addAgent
  57331. */
  57332. removeAgent(index: number): void;
  57333. /**
  57334. * get the list of all agents attached to this crowd
  57335. * @returns list of agent indices
  57336. */
  57337. getAgents(): number[];
  57338. /**
  57339. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57340. * @param deltaTime in seconds
  57341. */
  57342. update(deltaTime: number): void;
  57343. /**
  57344. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57345. * @param index agent index returned by addAgent
  57346. * @param destination targeted world position
  57347. */
  57348. agentGoto(index: number, destination: Vector3): void;
  57349. /**
  57350. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57351. * The queries will try to find a solution within those bounds
  57352. * default is (1,1,1)
  57353. * @param extent x,y,z value that define the extent around the queries point of reference
  57354. */
  57355. setDefaultQueryExtent(extent: Vector3): void;
  57356. /**
  57357. * Get the Bounding box extent specified by setDefaultQueryExtent
  57358. * @returns the box extent values
  57359. */
  57360. getDefaultQueryExtent(): Vector3;
  57361. /**
  57362. * Release all resources
  57363. */
  57364. dispose(): void;
  57365. }
  57366. /**
  57367. * Configures an agent
  57368. */
  57369. export interface IAgentParameters {
  57370. /**
  57371. * Agent radius. [Limit: >= 0]
  57372. */
  57373. radius: number;
  57374. /**
  57375. * Agent height. [Limit: > 0]
  57376. */
  57377. height: number;
  57378. /**
  57379. * Maximum allowed acceleration. [Limit: >= 0]
  57380. */
  57381. maxAcceleration: number;
  57382. /**
  57383. * Maximum allowed speed. [Limit: >= 0]
  57384. */
  57385. maxSpeed: number;
  57386. /**
  57387. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57388. */
  57389. collisionQueryRange: number;
  57390. /**
  57391. * The path visibility optimization range. [Limit: > 0]
  57392. */
  57393. pathOptimizationRange: number;
  57394. /**
  57395. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57396. */
  57397. separationWeight: number;
  57398. }
  57399. /**
  57400. * Configures the navigation mesh creation
  57401. */
  57402. export interface INavMeshParameters {
  57403. /**
  57404. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57405. */
  57406. cs: number;
  57407. /**
  57408. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57409. */
  57410. ch: number;
  57411. /**
  57412. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57413. */
  57414. walkableSlopeAngle: number;
  57415. /**
  57416. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57417. * be considered walkable. [Limit: >= 3] [Units: vx]
  57418. */
  57419. walkableHeight: number;
  57420. /**
  57421. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57422. */
  57423. walkableClimb: number;
  57424. /**
  57425. * The distance to erode/shrink the walkable area of the heightfield away from
  57426. * obstructions. [Limit: >=0] [Units: vx]
  57427. */
  57428. walkableRadius: number;
  57429. /**
  57430. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57431. */
  57432. maxEdgeLen: number;
  57433. /**
  57434. * The maximum distance a simplfied contour's border edges should deviate
  57435. * the original raw contour. [Limit: >=0] [Units: vx]
  57436. */
  57437. maxSimplificationError: number;
  57438. /**
  57439. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57440. */
  57441. minRegionArea: number;
  57442. /**
  57443. * Any regions with a span count smaller than this value will, if possible,
  57444. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57445. */
  57446. mergeRegionArea: number;
  57447. /**
  57448. * The maximum number of vertices allowed for polygons generated during the
  57449. * contour to polygon conversion process. [Limit: >= 3]
  57450. */
  57451. maxVertsPerPoly: number;
  57452. /**
  57453. * Sets the sampling distance to use when generating the detail mesh.
  57454. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57455. */
  57456. detailSampleDist: number;
  57457. /**
  57458. * The maximum distance the detail mesh surface should deviate from heightfield
  57459. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57460. */
  57461. detailSampleMaxError: number;
  57462. }
  57463. }
  57464. declare module BABYLON {
  57465. /**
  57466. * RecastJS navigation plugin
  57467. */
  57468. export class RecastJSPlugin implements INavigationEnginePlugin {
  57469. /**
  57470. * Reference to the Recast library
  57471. */
  57472. bjsRECAST: any;
  57473. /**
  57474. * plugin name
  57475. */
  57476. name: string;
  57477. /**
  57478. * the first navmesh created. We might extend this to support multiple navmeshes
  57479. */
  57480. navMesh: any;
  57481. /**
  57482. * Initializes the recastJS plugin
  57483. * @param recastInjection can be used to inject your own recast reference
  57484. */
  57485. constructor(recastInjection?: any);
  57486. /**
  57487. * Creates a navigation mesh
  57488. * @param meshes array of all the geometry used to compute the navigatio mesh
  57489. * @param parameters bunch of parameters used to filter geometry
  57490. */
  57491. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57492. /**
  57493. * Create a navigation mesh debug mesh
  57494. * @param scene is where the mesh will be added
  57495. * @returns debug display mesh
  57496. */
  57497. createDebugNavMesh(scene: Scene): Mesh;
  57498. /**
  57499. * Get a navigation mesh constrained position, closest to the parameter position
  57500. * @param position world position
  57501. * @returns the closest point to position constrained by the navigation mesh
  57502. */
  57503. getClosestPoint(position: Vector3): Vector3;
  57504. /**
  57505. * Get a navigation mesh constrained position, within a particular radius
  57506. * @param position world position
  57507. * @param maxRadius the maximum distance to the constrained world position
  57508. * @returns the closest point to position constrained by the navigation mesh
  57509. */
  57510. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57511. /**
  57512. * Compute the final position from a segment made of destination-position
  57513. * @param position world position
  57514. * @param destination world position
  57515. * @returns the resulting point along the navmesh
  57516. */
  57517. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57518. /**
  57519. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57520. * @param start world position
  57521. * @param end world position
  57522. * @returns array containing world position composing the path
  57523. */
  57524. computePath(start: Vector3, end: Vector3): Vector3[];
  57525. /**
  57526. * Create a new Crowd so you can add agents
  57527. * @param maxAgents the maximum agent count in the crowd
  57528. * @param maxAgentRadius the maximum radius an agent can have
  57529. * @param scene to attach the crowd to
  57530. * @returns the crowd you can add agents to
  57531. */
  57532. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57533. /**
  57534. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57535. * The queries will try to find a solution within those bounds
  57536. * default is (1,1,1)
  57537. * @param extent x,y,z value that define the extent around the queries point of reference
  57538. */
  57539. setDefaultQueryExtent(extent: Vector3): void;
  57540. /**
  57541. * Get the Bounding box extent specified by setDefaultQueryExtent
  57542. * @returns the box extent values
  57543. */
  57544. getDefaultQueryExtent(): Vector3;
  57545. /**
  57546. * Disposes
  57547. */
  57548. dispose(): void;
  57549. /**
  57550. * If this plugin is supported
  57551. * @returns true if plugin is supported
  57552. */
  57553. isSupported(): boolean;
  57554. }
  57555. /**
  57556. * Recast detour crowd implementation
  57557. */
  57558. export class RecastJSCrowd implements ICrowd {
  57559. /**
  57560. * Recast/detour plugin
  57561. */
  57562. bjsRECASTPlugin: RecastJSPlugin;
  57563. /**
  57564. * Link to the detour crowd
  57565. */
  57566. recastCrowd: any;
  57567. /**
  57568. * One transform per agent
  57569. */
  57570. transforms: TransformNode[];
  57571. /**
  57572. * All agents created
  57573. */
  57574. agents: number[];
  57575. /**
  57576. * Link to the scene is kept to unregister the crowd from the scene
  57577. */
  57578. private _scene;
  57579. /**
  57580. * Observer for crowd updates
  57581. */
  57582. private _onBeforeAnimationsObserver;
  57583. /**
  57584. * Constructor
  57585. * @param plugin recastJS plugin
  57586. * @param maxAgents the maximum agent count in the crowd
  57587. * @param maxAgentRadius the maximum radius an agent can have
  57588. * @param scene to attach the crowd to
  57589. * @returns the crowd you can add agents to
  57590. */
  57591. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  57592. /**
  57593. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57594. * You can attach anything to that node. The node position is updated in the scene update tick.
  57595. * @param pos world position that will be constrained by the navigation mesh
  57596. * @param parameters agent parameters
  57597. * @param transform hooked to the agent that will be update by the scene
  57598. * @returns agent index
  57599. */
  57600. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57601. /**
  57602. * Returns the agent position in world space
  57603. * @param index agent index returned by addAgent
  57604. * @returns world space position
  57605. */
  57606. getAgentPosition(index: number): Vector3;
  57607. /**
  57608. * Returns the agent velocity in world space
  57609. * @param index agent index returned by addAgent
  57610. * @returns world space velocity
  57611. */
  57612. getAgentVelocity(index: number): Vector3;
  57613. /**
  57614. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57615. * @param index agent index returned by addAgent
  57616. * @param destination targeted world position
  57617. */
  57618. agentGoto(index: number, destination: Vector3): void;
  57619. /**
  57620. * remove a particular agent previously created
  57621. * @param index agent index returned by addAgent
  57622. */
  57623. removeAgent(index: number): void;
  57624. /**
  57625. * get the list of all agents attached to this crowd
  57626. * @returns list of agent indices
  57627. */
  57628. getAgents(): number[];
  57629. /**
  57630. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57631. * @param deltaTime in seconds
  57632. */
  57633. update(deltaTime: number): void;
  57634. /**
  57635. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57636. * The queries will try to find a solution within those bounds
  57637. * default is (1,1,1)
  57638. * @param extent x,y,z value that define the extent around the queries point of reference
  57639. */
  57640. setDefaultQueryExtent(extent: Vector3): void;
  57641. /**
  57642. * Get the Bounding box extent specified by setDefaultQueryExtent
  57643. * @returns the box extent values
  57644. */
  57645. getDefaultQueryExtent(): Vector3;
  57646. /**
  57647. * Release all resources
  57648. */
  57649. dispose(): void;
  57650. }
  57651. }
  57652. declare module BABYLON {
  57653. /**
  57654. * Class used to enable access to IndexedDB
  57655. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57656. */
  57657. export class Database implements IOfflineProvider {
  57658. private _callbackManifestChecked;
  57659. private _currentSceneUrl;
  57660. private _db;
  57661. private _enableSceneOffline;
  57662. private _enableTexturesOffline;
  57663. private _manifestVersionFound;
  57664. private _mustUpdateRessources;
  57665. private _hasReachedQuota;
  57666. private _isSupported;
  57667. private _idbFactory;
  57668. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57669. private static IsUASupportingBlobStorage;
  57670. /**
  57671. * Gets a boolean indicating if Database storate is enabled (off by default)
  57672. */
  57673. static IDBStorageEnabled: boolean;
  57674. /**
  57675. * Gets a boolean indicating if scene must be saved in the database
  57676. */
  57677. readonly enableSceneOffline: boolean;
  57678. /**
  57679. * Gets a boolean indicating if textures must be saved in the database
  57680. */
  57681. readonly enableTexturesOffline: boolean;
  57682. /**
  57683. * Creates a new Database
  57684. * @param urlToScene defines the url to load the scene
  57685. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57686. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57687. */
  57688. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57689. private static _ParseURL;
  57690. private static _ReturnFullUrlLocation;
  57691. private _checkManifestFile;
  57692. /**
  57693. * Open the database and make it available
  57694. * @param successCallback defines the callback to call on success
  57695. * @param errorCallback defines the callback to call on error
  57696. */
  57697. open(successCallback: () => void, errorCallback: () => void): void;
  57698. /**
  57699. * Loads an image from the database
  57700. * @param url defines the url to load from
  57701. * @param image defines the target DOM image
  57702. */
  57703. loadImage(url: string, image: HTMLImageElement): void;
  57704. private _loadImageFromDBAsync;
  57705. private _saveImageIntoDBAsync;
  57706. private _checkVersionFromDB;
  57707. private _loadVersionFromDBAsync;
  57708. private _saveVersionIntoDBAsync;
  57709. /**
  57710. * Loads a file from database
  57711. * @param url defines the URL to load from
  57712. * @param sceneLoaded defines a callback to call on success
  57713. * @param progressCallBack defines a callback to call when progress changed
  57714. * @param errorCallback defines a callback to call on error
  57715. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57716. */
  57717. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57718. private _loadFileAsync;
  57719. private _saveFileAsync;
  57720. /**
  57721. * Validates if xhr data is correct
  57722. * @param xhr defines the request to validate
  57723. * @param dataType defines the expected data type
  57724. * @returns true if data is correct
  57725. */
  57726. private static _ValidateXHRData;
  57727. }
  57728. }
  57729. declare module BABYLON {
  57730. /** @hidden */
  57731. export var gpuUpdateParticlesPixelShader: {
  57732. name: string;
  57733. shader: string;
  57734. };
  57735. }
  57736. declare module BABYLON {
  57737. /** @hidden */
  57738. export var gpuUpdateParticlesVertexShader: {
  57739. name: string;
  57740. shader: string;
  57741. };
  57742. }
  57743. declare module BABYLON {
  57744. /** @hidden */
  57745. export var clipPlaneFragmentDeclaration2: {
  57746. name: string;
  57747. shader: string;
  57748. };
  57749. }
  57750. declare module BABYLON {
  57751. /** @hidden */
  57752. export var gpuRenderParticlesPixelShader: {
  57753. name: string;
  57754. shader: string;
  57755. };
  57756. }
  57757. declare module BABYLON {
  57758. /** @hidden */
  57759. export var clipPlaneVertexDeclaration2: {
  57760. name: string;
  57761. shader: string;
  57762. };
  57763. }
  57764. declare module BABYLON {
  57765. /** @hidden */
  57766. export var gpuRenderParticlesVertexShader: {
  57767. name: string;
  57768. shader: string;
  57769. };
  57770. }
  57771. declare module BABYLON {
  57772. /**
  57773. * This represents a GPU particle system in Babylon
  57774. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57775. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57776. */
  57777. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57778. /**
  57779. * The layer mask we are rendering the particles through.
  57780. */
  57781. layerMask: number;
  57782. private _capacity;
  57783. private _activeCount;
  57784. private _currentActiveCount;
  57785. private _accumulatedCount;
  57786. private _renderEffect;
  57787. private _updateEffect;
  57788. private _buffer0;
  57789. private _buffer1;
  57790. private _spriteBuffer;
  57791. private _updateVAO;
  57792. private _renderVAO;
  57793. private _targetIndex;
  57794. private _sourceBuffer;
  57795. private _targetBuffer;
  57796. private _engine;
  57797. private _currentRenderId;
  57798. private _started;
  57799. private _stopped;
  57800. private _timeDelta;
  57801. private _randomTexture;
  57802. private _randomTexture2;
  57803. private _attributesStrideSize;
  57804. private _updateEffectOptions;
  57805. private _randomTextureSize;
  57806. private _actualFrame;
  57807. private readonly _rawTextureWidth;
  57808. /**
  57809. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  57810. */
  57811. static readonly IsSupported: boolean;
  57812. /**
  57813. * An event triggered when the system is disposed.
  57814. */
  57815. onDisposeObservable: Observable<GPUParticleSystem>;
  57816. /**
  57817. * Gets the maximum number of particles active at the same time.
  57818. * @returns The max number of active particles.
  57819. */
  57820. getCapacity(): number;
  57821. /**
  57822. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57823. * to override the particles.
  57824. */
  57825. forceDepthWrite: boolean;
  57826. /**
  57827. * Gets or set the number of active particles
  57828. */
  57829. activeParticleCount: number;
  57830. private _preWarmDone;
  57831. /**
  57832. * Is this system ready to be used/rendered
  57833. * @return true if the system is ready
  57834. */
  57835. isReady(): boolean;
  57836. /**
  57837. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57838. * @returns True if it has been started, otherwise false.
  57839. */
  57840. isStarted(): boolean;
  57841. /**
  57842. * Starts the particle system and begins to emit
  57843. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57844. */
  57845. start(delay?: number): void;
  57846. /**
  57847. * Stops the particle system.
  57848. */
  57849. stop(): void;
  57850. /**
  57851. * Remove all active particles
  57852. */
  57853. reset(): void;
  57854. /**
  57855. * Returns the string "GPUParticleSystem"
  57856. * @returns a string containing the class name
  57857. */
  57858. getClassName(): string;
  57859. private _colorGradientsTexture;
  57860. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57861. /**
  57862. * Adds a new color gradient
  57863. * @param gradient defines the gradient to use (between 0 and 1)
  57864. * @param color1 defines the color to affect to the specified gradient
  57865. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57866. * @returns the current particle system
  57867. */
  57868. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57869. /**
  57870. * Remove a specific color gradient
  57871. * @param gradient defines the gradient to remove
  57872. * @returns the current particle system
  57873. */
  57874. removeColorGradient(gradient: number): GPUParticleSystem;
  57875. private _angularSpeedGradientsTexture;
  57876. private _sizeGradientsTexture;
  57877. private _velocityGradientsTexture;
  57878. private _limitVelocityGradientsTexture;
  57879. private _dragGradientsTexture;
  57880. private _addFactorGradient;
  57881. /**
  57882. * Adds a new size gradient
  57883. * @param gradient defines the gradient to use (between 0 and 1)
  57884. * @param factor defines the size factor to affect to the specified gradient
  57885. * @returns the current particle system
  57886. */
  57887. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57888. /**
  57889. * Remove a specific size gradient
  57890. * @param gradient defines the gradient to remove
  57891. * @returns the current particle system
  57892. */
  57893. removeSizeGradient(gradient: number): GPUParticleSystem;
  57894. /**
  57895. * Adds a new angular speed gradient
  57896. * @param gradient defines the gradient to use (between 0 and 1)
  57897. * @param factor defines the angular speed to affect to the specified gradient
  57898. * @returns the current particle system
  57899. */
  57900. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57901. /**
  57902. * Remove a specific angular speed gradient
  57903. * @param gradient defines the gradient to remove
  57904. * @returns the current particle system
  57905. */
  57906. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57907. /**
  57908. * Adds a new velocity gradient
  57909. * @param gradient defines the gradient to use (between 0 and 1)
  57910. * @param factor defines the velocity to affect to the specified gradient
  57911. * @returns the current particle system
  57912. */
  57913. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57914. /**
  57915. * Remove a specific velocity gradient
  57916. * @param gradient defines the gradient to remove
  57917. * @returns the current particle system
  57918. */
  57919. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57920. /**
  57921. * Adds a new limit velocity gradient
  57922. * @param gradient defines the gradient to use (between 0 and 1)
  57923. * @param factor defines the limit velocity value to affect to the specified gradient
  57924. * @returns the current particle system
  57925. */
  57926. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57927. /**
  57928. * Remove a specific limit velocity gradient
  57929. * @param gradient defines the gradient to remove
  57930. * @returns the current particle system
  57931. */
  57932. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57933. /**
  57934. * Adds a new drag gradient
  57935. * @param gradient defines the gradient to use (between 0 and 1)
  57936. * @param factor defines the drag value to affect to the specified gradient
  57937. * @returns the current particle system
  57938. */
  57939. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57940. /**
  57941. * Remove a specific drag gradient
  57942. * @param gradient defines the gradient to remove
  57943. * @returns the current particle system
  57944. */
  57945. removeDragGradient(gradient: number): GPUParticleSystem;
  57946. /**
  57947. * Not supported by GPUParticleSystem
  57948. * @param gradient defines the gradient to use (between 0 and 1)
  57949. * @param factor defines the emit rate value to affect to the specified gradient
  57950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57951. * @returns the current particle system
  57952. */
  57953. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57954. /**
  57955. * Not supported by GPUParticleSystem
  57956. * @param gradient defines the gradient to remove
  57957. * @returns the current particle system
  57958. */
  57959. removeEmitRateGradient(gradient: number): IParticleSystem;
  57960. /**
  57961. * Not supported by GPUParticleSystem
  57962. * @param gradient defines the gradient to use (between 0 and 1)
  57963. * @param factor defines the start size value to affect to the specified gradient
  57964. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57965. * @returns the current particle system
  57966. */
  57967. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57968. /**
  57969. * Not supported by GPUParticleSystem
  57970. * @param gradient defines the gradient to remove
  57971. * @returns the current particle system
  57972. */
  57973. removeStartSizeGradient(gradient: number): IParticleSystem;
  57974. /**
  57975. * Not supported by GPUParticleSystem
  57976. * @param gradient defines the gradient to use (between 0 and 1)
  57977. * @param min defines the color remap minimal range
  57978. * @param max defines the color remap maximal range
  57979. * @returns the current particle system
  57980. */
  57981. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57982. /**
  57983. * Not supported by GPUParticleSystem
  57984. * @param gradient defines the gradient to remove
  57985. * @returns the current particle system
  57986. */
  57987. removeColorRemapGradient(): IParticleSystem;
  57988. /**
  57989. * Not supported by GPUParticleSystem
  57990. * @param gradient defines the gradient to use (between 0 and 1)
  57991. * @param min defines the alpha remap minimal range
  57992. * @param max defines the alpha remap maximal range
  57993. * @returns the current particle system
  57994. */
  57995. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57996. /**
  57997. * Not supported by GPUParticleSystem
  57998. * @param gradient defines the gradient to remove
  57999. * @returns the current particle system
  58000. */
  58001. removeAlphaRemapGradient(): IParticleSystem;
  58002. /**
  58003. * Not supported by GPUParticleSystem
  58004. * @param gradient defines the gradient to use (between 0 and 1)
  58005. * @param color defines the color to affect to the specified gradient
  58006. * @returns the current particle system
  58007. */
  58008. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58009. /**
  58010. * Not supported by GPUParticleSystem
  58011. * @param gradient defines the gradient to remove
  58012. * @returns the current particle system
  58013. */
  58014. removeRampGradient(): IParticleSystem;
  58015. /**
  58016. * Not supported by GPUParticleSystem
  58017. * @returns the list of ramp gradients
  58018. */
  58019. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58020. /**
  58021. * Not supported by GPUParticleSystem
  58022. * Gets or sets a boolean indicating that ramp gradients must be used
  58023. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58024. */
  58025. useRampGradients: boolean;
  58026. /**
  58027. * Not supported by GPUParticleSystem
  58028. * @param gradient defines the gradient to use (between 0 and 1)
  58029. * @param factor defines the life time factor to affect to the specified gradient
  58030. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58031. * @returns the current particle system
  58032. */
  58033. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58034. /**
  58035. * Not supported by GPUParticleSystem
  58036. * @param gradient defines the gradient to remove
  58037. * @returns the current particle system
  58038. */
  58039. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58040. /**
  58041. * Instantiates a GPU particle system.
  58042. * 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.
  58043. * @param name The name of the particle system
  58044. * @param options The options used to create the system
  58045. * @param scene The scene the particle system belongs to
  58046. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58047. */
  58048. constructor(name: string, options: Partial<{
  58049. capacity: number;
  58050. randomTextureSize: number;
  58051. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58052. protected _reset(): void;
  58053. private _createUpdateVAO;
  58054. private _createRenderVAO;
  58055. private _initialize;
  58056. /** @hidden */
  58057. _recreateUpdateEffect(): void;
  58058. /** @hidden */
  58059. _recreateRenderEffect(): void;
  58060. /**
  58061. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58062. * @param preWarm defines if we are in the pre-warmimg phase
  58063. */
  58064. animate(preWarm?: boolean): void;
  58065. private _createFactorGradientTexture;
  58066. private _createSizeGradientTexture;
  58067. private _createAngularSpeedGradientTexture;
  58068. private _createVelocityGradientTexture;
  58069. private _createLimitVelocityGradientTexture;
  58070. private _createDragGradientTexture;
  58071. private _createColorGradientTexture;
  58072. /**
  58073. * Renders the particle system in its current state
  58074. * @param preWarm defines if the system should only update the particles but not render them
  58075. * @returns the current number of particles
  58076. */
  58077. render(preWarm?: boolean): number;
  58078. /**
  58079. * Rebuilds the particle system
  58080. */
  58081. rebuild(): void;
  58082. private _releaseBuffers;
  58083. private _releaseVAOs;
  58084. /**
  58085. * Disposes the particle system and free the associated resources
  58086. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58087. */
  58088. dispose(disposeTexture?: boolean): void;
  58089. /**
  58090. * Clones the particle system.
  58091. * @param name The name of the cloned object
  58092. * @param newEmitter The new emitter to use
  58093. * @returns the cloned particle system
  58094. */
  58095. clone(name: string, newEmitter: any): GPUParticleSystem;
  58096. /**
  58097. * Serializes the particle system to a JSON object.
  58098. * @returns the JSON object
  58099. */
  58100. serialize(): any;
  58101. /**
  58102. * Parses a JSON object to create a GPU particle system.
  58103. * @param parsedParticleSystem The JSON object to parse
  58104. * @param scene The scene to create the particle system in
  58105. * @param rootUrl The root url to use to load external dependencies like texture
  58106. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58107. * @returns the parsed GPU particle system
  58108. */
  58109. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58110. }
  58111. }
  58112. declare module BABYLON {
  58113. /**
  58114. * Represents a set of particle systems working together to create a specific effect
  58115. */
  58116. export class ParticleSystemSet implements IDisposable {
  58117. private _emitterCreationOptions;
  58118. private _emitterNode;
  58119. /**
  58120. * Gets the particle system list
  58121. */
  58122. systems: IParticleSystem[];
  58123. /**
  58124. * Gets the emitter node used with this set
  58125. */
  58126. readonly emitterNode: Nullable<TransformNode>;
  58127. /**
  58128. * Creates a new emitter mesh as a sphere
  58129. * @param options defines the options used to create the sphere
  58130. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58131. * @param scene defines the hosting scene
  58132. */
  58133. setEmitterAsSphere(options: {
  58134. diameter: number;
  58135. segments: number;
  58136. color: Color3;
  58137. }, renderingGroupId: number, scene: Scene): void;
  58138. /**
  58139. * Starts all particle systems of the set
  58140. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58141. */
  58142. start(emitter?: AbstractMesh): void;
  58143. /**
  58144. * Release all associated resources
  58145. */
  58146. dispose(): void;
  58147. /**
  58148. * Serialize the set into a JSON compatible object
  58149. * @returns a JSON compatible representation of the set
  58150. */
  58151. serialize(): any;
  58152. /**
  58153. * Parse a new ParticleSystemSet from a serialized source
  58154. * @param data defines a JSON compatible representation of the set
  58155. * @param scene defines the hosting scene
  58156. * @param gpu defines if we want GPU particles or CPU particles
  58157. * @returns a new ParticleSystemSet
  58158. */
  58159. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58160. }
  58161. }
  58162. declare module BABYLON {
  58163. /**
  58164. * This class is made for on one-liner static method to help creating particle system set.
  58165. */
  58166. export class ParticleHelper {
  58167. /**
  58168. * Gets or sets base Assets URL
  58169. */
  58170. static BaseAssetsUrl: string;
  58171. /**
  58172. * Create a default particle system that you can tweak
  58173. * @param emitter defines the emitter to use
  58174. * @param capacity defines the system capacity (default is 500 particles)
  58175. * @param scene defines the hosting scene
  58176. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58177. * @returns the new Particle system
  58178. */
  58179. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58180. /**
  58181. * This is the main static method (one-liner) of this helper to create different particle systems
  58182. * @param type This string represents the type to the particle system to create
  58183. * @param scene The scene where the particle system should live
  58184. * @param gpu If the system will use gpu
  58185. * @returns the ParticleSystemSet created
  58186. */
  58187. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58188. /**
  58189. * Static function used to export a particle system to a ParticleSystemSet variable.
  58190. * Please note that the emitter shape is not exported
  58191. * @param systems defines the particle systems to export
  58192. * @returns the created particle system set
  58193. */
  58194. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58195. }
  58196. }
  58197. declare module BABYLON {
  58198. interface Engine {
  58199. /**
  58200. * Create an effect to use with particle systems.
  58201. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58202. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58203. * @param uniformsNames defines a list of attribute names
  58204. * @param samplers defines an array of string used to represent textures
  58205. * @param defines defines the string containing the defines to use to compile the shaders
  58206. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58207. * @param onCompiled defines a function to call when the effect creation is successful
  58208. * @param onError defines a function to call when the effect creation has failed
  58209. * @returns the new Effect
  58210. */
  58211. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58212. }
  58213. interface Mesh {
  58214. /**
  58215. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58216. * @returns an array of IParticleSystem
  58217. */
  58218. getEmittedParticleSystems(): IParticleSystem[];
  58219. /**
  58220. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58221. * @returns an array of IParticleSystem
  58222. */
  58223. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58224. }
  58225. /**
  58226. * @hidden
  58227. */
  58228. export var _IDoNeedToBeInTheBuild: number;
  58229. }
  58230. declare module BABYLON {
  58231. interface Scene {
  58232. /** @hidden (Backing field) */
  58233. _physicsEngine: Nullable<IPhysicsEngine>;
  58234. /**
  58235. * Gets the current physics engine
  58236. * @returns a IPhysicsEngine or null if none attached
  58237. */
  58238. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  58239. /**
  58240. * Enables physics to the current scene
  58241. * @param gravity defines the scene's gravity for the physics engine
  58242. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  58243. * @return a boolean indicating if the physics engine was initialized
  58244. */
  58245. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  58246. /**
  58247. * Disables and disposes the physics engine associated with the scene
  58248. */
  58249. disablePhysicsEngine(): void;
  58250. /**
  58251. * Gets a boolean indicating if there is an active physics engine
  58252. * @returns a boolean indicating if there is an active physics engine
  58253. */
  58254. isPhysicsEnabled(): boolean;
  58255. /**
  58256. * Deletes a physics compound impostor
  58257. * @param compound defines the compound to delete
  58258. */
  58259. deleteCompoundImpostor(compound: any): void;
  58260. /**
  58261. * An event triggered when physic simulation is about to be run
  58262. */
  58263. onBeforePhysicsObservable: Observable<Scene>;
  58264. /**
  58265. * An event triggered when physic simulation has been done
  58266. */
  58267. onAfterPhysicsObservable: Observable<Scene>;
  58268. }
  58269. interface AbstractMesh {
  58270. /** @hidden */
  58271. _physicsImpostor: Nullable<PhysicsImpostor>;
  58272. /**
  58273. * Gets or sets impostor used for physic simulation
  58274. * @see http://doc.babylonjs.com/features/physics_engine
  58275. */
  58276. physicsImpostor: Nullable<PhysicsImpostor>;
  58277. /**
  58278. * Gets the current physics impostor
  58279. * @see http://doc.babylonjs.com/features/physics_engine
  58280. * @returns a physics impostor or null
  58281. */
  58282. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58283. /** Apply a physic impulse to the mesh
  58284. * @param force defines the force to apply
  58285. * @param contactPoint defines where to apply the force
  58286. * @returns the current mesh
  58287. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58288. */
  58289. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58290. /**
  58291. * Creates a physic joint between two meshes
  58292. * @param otherMesh defines the other mesh to use
  58293. * @param pivot1 defines the pivot to use on this mesh
  58294. * @param pivot2 defines the pivot to use on the other mesh
  58295. * @param options defines additional options (can be plugin dependent)
  58296. * @returns the current mesh
  58297. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58298. */
  58299. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58300. /** @hidden */
  58301. _disposePhysicsObserver: Nullable<Observer<Node>>;
  58302. }
  58303. /**
  58304. * Defines the physics engine scene component responsible to manage a physics engine
  58305. */
  58306. export class PhysicsEngineSceneComponent implements ISceneComponent {
  58307. /**
  58308. * The component name helpful to identify the component in the list of scene components.
  58309. */
  58310. readonly name: string;
  58311. /**
  58312. * The scene the component belongs to.
  58313. */
  58314. scene: Scene;
  58315. /**
  58316. * Creates a new instance of the component for the given scene
  58317. * @param scene Defines the scene to register the component in
  58318. */
  58319. constructor(scene: Scene);
  58320. /**
  58321. * Registers the component in a given scene
  58322. */
  58323. register(): void;
  58324. /**
  58325. * Rebuilds the elements related to this component in case of
  58326. * context lost for instance.
  58327. */
  58328. rebuild(): void;
  58329. /**
  58330. * Disposes the component and the associated ressources
  58331. */
  58332. dispose(): void;
  58333. }
  58334. }
  58335. declare module BABYLON {
  58336. /**
  58337. * A helper for physics simulations
  58338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58339. */
  58340. export class PhysicsHelper {
  58341. private _scene;
  58342. private _physicsEngine;
  58343. /**
  58344. * Initializes the Physics helper
  58345. * @param scene Babylon.js scene
  58346. */
  58347. constructor(scene: Scene);
  58348. /**
  58349. * Applies a radial explosion impulse
  58350. * @param origin the origin of the explosion
  58351. * @param radiusOrEventOptions the radius or the options of radial explosion
  58352. * @param strength the explosion strength
  58353. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58354. * @returns A physics radial explosion event, or null
  58355. */
  58356. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58357. /**
  58358. * Applies a radial explosion force
  58359. * @param origin the origin of the explosion
  58360. * @param radiusOrEventOptions the radius or the options of radial explosion
  58361. * @param strength the explosion strength
  58362. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58363. * @returns A physics radial explosion event, or null
  58364. */
  58365. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58366. /**
  58367. * Creates a gravitational field
  58368. * @param origin the origin of the explosion
  58369. * @param radiusOrEventOptions the radius or the options of radial explosion
  58370. * @param strength the explosion strength
  58371. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58372. * @returns A physics gravitational field event, or null
  58373. */
  58374. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  58375. /**
  58376. * Creates a physics updraft event
  58377. * @param origin the origin of the updraft
  58378. * @param radiusOrEventOptions the radius or the options of the updraft
  58379. * @param strength the strength of the updraft
  58380. * @param height the height of the updraft
  58381. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  58382. * @returns A physics updraft event, or null
  58383. */
  58384. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  58385. /**
  58386. * Creates a physics vortex event
  58387. * @param origin the of the vortex
  58388. * @param radiusOrEventOptions the radius or the options of the vortex
  58389. * @param strength the strength of the vortex
  58390. * @param height the height of the vortex
  58391. * @returns a Physics vortex event, or null
  58392. * A physics vortex event or null
  58393. */
  58394. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  58395. }
  58396. /**
  58397. * Represents a physics radial explosion event
  58398. */
  58399. class PhysicsRadialExplosionEvent {
  58400. private _scene;
  58401. private _options;
  58402. private _sphere;
  58403. private _dataFetched;
  58404. /**
  58405. * Initializes a radial explosioin event
  58406. * @param _scene BabylonJS scene
  58407. * @param _options The options for the vortex event
  58408. */
  58409. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58410. /**
  58411. * Returns the data related to the radial explosion event (sphere).
  58412. * @returns The radial explosion event data
  58413. */
  58414. getData(): PhysicsRadialExplosionEventData;
  58415. /**
  58416. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58417. * @param impostor A physics imposter
  58418. * @param origin the origin of the explosion
  58419. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58420. */
  58421. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58422. /**
  58423. * Triggers affecterd impostors callbacks
  58424. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58425. */
  58426. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58427. /**
  58428. * Disposes the sphere.
  58429. * @param force Specifies if the sphere should be disposed by force
  58430. */
  58431. dispose(force?: boolean): void;
  58432. /*** Helpers ***/
  58433. private _prepareSphere;
  58434. private _intersectsWithSphere;
  58435. }
  58436. /**
  58437. * Represents a gravitational field event
  58438. */
  58439. class PhysicsGravitationalFieldEvent {
  58440. private _physicsHelper;
  58441. private _scene;
  58442. private _origin;
  58443. private _options;
  58444. private _tickCallback;
  58445. private _sphere;
  58446. private _dataFetched;
  58447. /**
  58448. * Initializes the physics gravitational field event
  58449. * @param _physicsHelper A physics helper
  58450. * @param _scene BabylonJS scene
  58451. * @param _origin The origin position of the gravitational field event
  58452. * @param _options The options for the vortex event
  58453. */
  58454. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58455. /**
  58456. * Returns the data related to the gravitational field event (sphere).
  58457. * @returns A gravitational field event
  58458. */
  58459. getData(): PhysicsGravitationalFieldEventData;
  58460. /**
  58461. * Enables the gravitational field.
  58462. */
  58463. enable(): void;
  58464. /**
  58465. * Disables the gravitational field.
  58466. */
  58467. disable(): void;
  58468. /**
  58469. * Disposes the sphere.
  58470. * @param force The force to dispose from the gravitational field event
  58471. */
  58472. dispose(force?: boolean): void;
  58473. private _tick;
  58474. }
  58475. /**
  58476. * Represents a physics updraft event
  58477. */
  58478. class PhysicsUpdraftEvent {
  58479. private _scene;
  58480. private _origin;
  58481. private _options;
  58482. private _physicsEngine;
  58483. private _originTop;
  58484. private _originDirection;
  58485. private _tickCallback;
  58486. private _cylinder;
  58487. private _cylinderPosition;
  58488. private _dataFetched;
  58489. /**
  58490. * Initializes the physics updraft event
  58491. * @param _scene BabylonJS scene
  58492. * @param _origin The origin position of the updraft
  58493. * @param _options The options for the updraft event
  58494. */
  58495. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  58496. /**
  58497. * Returns the data related to the updraft event (cylinder).
  58498. * @returns A physics updraft event
  58499. */
  58500. getData(): PhysicsUpdraftEventData;
  58501. /**
  58502. * Enables the updraft.
  58503. */
  58504. enable(): void;
  58505. /**
  58506. * Disables the updraft.
  58507. */
  58508. disable(): void;
  58509. /**
  58510. * Disposes the cylinder.
  58511. * @param force Specifies if the updraft should be disposed by force
  58512. */
  58513. dispose(force?: boolean): void;
  58514. private getImpostorHitData;
  58515. private _tick;
  58516. /*** Helpers ***/
  58517. private _prepareCylinder;
  58518. private _intersectsWithCylinder;
  58519. }
  58520. /**
  58521. * Represents a physics vortex event
  58522. */
  58523. class PhysicsVortexEvent {
  58524. private _scene;
  58525. private _origin;
  58526. private _options;
  58527. private _physicsEngine;
  58528. private _originTop;
  58529. private _tickCallback;
  58530. private _cylinder;
  58531. private _cylinderPosition;
  58532. private _dataFetched;
  58533. /**
  58534. * Initializes the physics vortex event
  58535. * @param _scene The BabylonJS scene
  58536. * @param _origin The origin position of the vortex
  58537. * @param _options The options for the vortex event
  58538. */
  58539. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  58540. /**
  58541. * Returns the data related to the vortex event (cylinder).
  58542. * @returns The physics vortex event data
  58543. */
  58544. getData(): PhysicsVortexEventData;
  58545. /**
  58546. * Enables the vortex.
  58547. */
  58548. enable(): void;
  58549. /**
  58550. * Disables the cortex.
  58551. */
  58552. disable(): void;
  58553. /**
  58554. * Disposes the sphere.
  58555. * @param force
  58556. */
  58557. dispose(force?: boolean): void;
  58558. private getImpostorHitData;
  58559. private _tick;
  58560. /*** Helpers ***/
  58561. private _prepareCylinder;
  58562. private _intersectsWithCylinder;
  58563. }
  58564. /**
  58565. * Options fot the radial explosion event
  58566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58567. */
  58568. export class PhysicsRadialExplosionEventOptions {
  58569. /**
  58570. * The radius of the sphere for the radial explosion.
  58571. */
  58572. radius: number;
  58573. /**
  58574. * The strenth of the explosion.
  58575. */
  58576. strength: number;
  58577. /**
  58578. * The strenght of the force in correspondence to the distance of the affected object
  58579. */
  58580. falloff: PhysicsRadialImpulseFalloff;
  58581. /**
  58582. * Sphere options for the radial explosion.
  58583. */
  58584. sphere: {
  58585. segments: number;
  58586. diameter: number;
  58587. };
  58588. /**
  58589. * Sphere options for the radial explosion.
  58590. */
  58591. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  58592. }
  58593. /**
  58594. * Options fot the updraft event
  58595. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58596. */
  58597. export class PhysicsUpdraftEventOptions {
  58598. /**
  58599. * The radius of the cylinder for the vortex
  58600. */
  58601. radius: number;
  58602. /**
  58603. * The strenth of the updraft.
  58604. */
  58605. strength: number;
  58606. /**
  58607. * The height of the cylinder for the updraft.
  58608. */
  58609. height: number;
  58610. /**
  58611. * The mode for the the updraft.
  58612. */
  58613. updraftMode: PhysicsUpdraftMode;
  58614. }
  58615. /**
  58616. * Options fot the vortex event
  58617. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58618. */
  58619. export class PhysicsVortexEventOptions {
  58620. /**
  58621. * The radius of the cylinder for the vortex
  58622. */
  58623. radius: number;
  58624. /**
  58625. * The strenth of the vortex.
  58626. */
  58627. strength: number;
  58628. /**
  58629. * The height of the cylinder for the vortex.
  58630. */
  58631. height: number;
  58632. /**
  58633. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  58634. */
  58635. centripetalForceThreshold: number;
  58636. /**
  58637. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  58638. */
  58639. centripetalForceMultiplier: number;
  58640. /**
  58641. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  58642. */
  58643. centrifugalForceMultiplier: number;
  58644. /**
  58645. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  58646. */
  58647. updraftForceMultiplier: number;
  58648. }
  58649. /**
  58650. * The strenght of the force in correspondence to the distance of the affected object
  58651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58652. */
  58653. export enum PhysicsRadialImpulseFalloff {
  58654. /** Defines that impulse is constant in strength across it's whole radius */
  58655. Constant = 0,
  58656. /** Defines that impulse gets weaker if it's further from the origin */
  58657. Linear = 1
  58658. }
  58659. /**
  58660. * The strength of the force in correspondence to the distance of the affected object
  58661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58662. */
  58663. export enum PhysicsUpdraftMode {
  58664. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  58665. Center = 0,
  58666. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  58667. Perpendicular = 1
  58668. }
  58669. /**
  58670. * Interface for a physics hit data
  58671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58672. */
  58673. export interface PhysicsHitData {
  58674. /**
  58675. * The force applied at the contact point
  58676. */
  58677. force: Vector3;
  58678. /**
  58679. * The contact point
  58680. */
  58681. contactPoint: Vector3;
  58682. /**
  58683. * The distance from the origin to the contact point
  58684. */
  58685. distanceFromOrigin: number;
  58686. }
  58687. /**
  58688. * Interface for radial explosion event data
  58689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58690. */
  58691. export interface PhysicsRadialExplosionEventData {
  58692. /**
  58693. * A sphere used for the radial explosion event
  58694. */
  58695. sphere: Mesh;
  58696. }
  58697. /**
  58698. * Interface for gravitational field event data
  58699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58700. */
  58701. export interface PhysicsGravitationalFieldEventData {
  58702. /**
  58703. * A sphere mesh used for the gravitational field event
  58704. */
  58705. sphere: Mesh;
  58706. }
  58707. /**
  58708. * Interface for updraft event data
  58709. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58710. */
  58711. export interface PhysicsUpdraftEventData {
  58712. /**
  58713. * A cylinder used for the updraft event
  58714. */
  58715. cylinder: Mesh;
  58716. }
  58717. /**
  58718. * Interface for vortex event data
  58719. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58720. */
  58721. export interface PhysicsVortexEventData {
  58722. /**
  58723. * A cylinder used for the vortex event
  58724. */
  58725. cylinder: Mesh;
  58726. }
  58727. /**
  58728. * Interface for an affected physics impostor
  58729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58730. */
  58731. export interface PhysicsAffectedImpostorWithData {
  58732. /**
  58733. * The impostor affected by the effect
  58734. */
  58735. impostor: PhysicsImpostor;
  58736. /**
  58737. * The data about the hit/horce from the explosion
  58738. */
  58739. hitData: PhysicsHitData;
  58740. }
  58741. }
  58742. declare module BABYLON {
  58743. /** @hidden */
  58744. export var blackAndWhitePixelShader: {
  58745. name: string;
  58746. shader: string;
  58747. };
  58748. }
  58749. declare module BABYLON {
  58750. /**
  58751. * Post process used to render in black and white
  58752. */
  58753. export class BlackAndWhitePostProcess extends PostProcess {
  58754. /**
  58755. * Linear about to convert he result to black and white (default: 1)
  58756. */
  58757. degree: number;
  58758. /**
  58759. * Creates a black and white post process
  58760. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  58761. * @param name The name of the effect.
  58762. * @param options The required width/height ratio to downsize to before computing the render pass.
  58763. * @param camera The camera to apply the render pass to.
  58764. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58765. * @param engine The engine which the post process will be applied. (default: current engine)
  58766. * @param reusable If the post process can be reused on the same frame. (default: false)
  58767. */
  58768. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58769. }
  58770. }
  58771. declare module BABYLON {
  58772. /**
  58773. * This represents a set of one or more post processes in Babylon.
  58774. * A post process can be used to apply a shader to a texture after it is rendered.
  58775. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58776. */
  58777. export class PostProcessRenderEffect {
  58778. private _postProcesses;
  58779. private _getPostProcesses;
  58780. private _singleInstance;
  58781. private _cameras;
  58782. private _indicesForCamera;
  58783. /**
  58784. * Name of the effect
  58785. * @hidden
  58786. */
  58787. _name: string;
  58788. /**
  58789. * Instantiates a post process render effect.
  58790. * A post process can be used to apply a shader to a texture after it is rendered.
  58791. * @param engine The engine the effect is tied to
  58792. * @param name The name of the effect
  58793. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  58794. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  58795. */
  58796. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  58797. /**
  58798. * Checks if all the post processes in the effect are supported.
  58799. */
  58800. readonly isSupported: boolean;
  58801. /**
  58802. * Updates the current state of the effect
  58803. * @hidden
  58804. */
  58805. _update(): void;
  58806. /**
  58807. * Attaches the effect on cameras
  58808. * @param cameras The camera to attach to.
  58809. * @hidden
  58810. */
  58811. _attachCameras(cameras: Camera): void;
  58812. /**
  58813. * Attaches the effect on cameras
  58814. * @param cameras The camera to attach to.
  58815. * @hidden
  58816. */
  58817. _attachCameras(cameras: Camera[]): void;
  58818. /**
  58819. * Detaches the effect on cameras
  58820. * @param cameras The camera to detatch from.
  58821. * @hidden
  58822. */
  58823. _detachCameras(cameras: Camera): void;
  58824. /**
  58825. * Detatches the effect on cameras
  58826. * @param cameras The camera to detatch from.
  58827. * @hidden
  58828. */
  58829. _detachCameras(cameras: Camera[]): void;
  58830. /**
  58831. * Enables the effect on given cameras
  58832. * @param cameras The camera to enable.
  58833. * @hidden
  58834. */
  58835. _enable(cameras: Camera): void;
  58836. /**
  58837. * Enables the effect on given cameras
  58838. * @param cameras The camera to enable.
  58839. * @hidden
  58840. */
  58841. _enable(cameras: Nullable<Camera[]>): void;
  58842. /**
  58843. * Disables the effect on the given cameras
  58844. * @param cameras The camera to disable.
  58845. * @hidden
  58846. */
  58847. _disable(cameras: Camera): void;
  58848. /**
  58849. * Disables the effect on the given cameras
  58850. * @param cameras The camera to disable.
  58851. * @hidden
  58852. */
  58853. _disable(cameras: Nullable<Camera[]>): void;
  58854. /**
  58855. * Gets a list of the post processes contained in the effect.
  58856. * @param camera The camera to get the post processes on.
  58857. * @returns The list of the post processes in the effect.
  58858. */
  58859. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  58860. }
  58861. }
  58862. declare module BABYLON {
  58863. /** @hidden */
  58864. export var extractHighlightsPixelShader: {
  58865. name: string;
  58866. shader: string;
  58867. };
  58868. }
  58869. declare module BABYLON {
  58870. /**
  58871. * 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.
  58872. */
  58873. export class ExtractHighlightsPostProcess extends PostProcess {
  58874. /**
  58875. * The luminance threshold, pixels below this value will be set to black.
  58876. */
  58877. threshold: number;
  58878. /** @hidden */
  58879. _exposure: number;
  58880. /**
  58881. * Post process which has the input texture to be used when performing highlight extraction
  58882. * @hidden
  58883. */
  58884. _inputPostProcess: Nullable<PostProcess>;
  58885. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58886. }
  58887. }
  58888. declare module BABYLON {
  58889. /** @hidden */
  58890. export var bloomMergePixelShader: {
  58891. name: string;
  58892. shader: string;
  58893. };
  58894. }
  58895. declare module BABYLON {
  58896. /**
  58897. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58898. */
  58899. export class BloomMergePostProcess extends PostProcess {
  58900. /** Weight of the bloom to be added to the original input. */
  58901. weight: number;
  58902. /**
  58903. * Creates a new instance of @see BloomMergePostProcess
  58904. * @param name The name of the effect.
  58905. * @param originalFromInput Post process which's input will be used for the merge.
  58906. * @param blurred Blurred highlights post process which's output will be used.
  58907. * @param weight Weight of the bloom to be added to the original input.
  58908. * @param options The required width/height ratio to downsize to before computing the render pass.
  58909. * @param camera The camera to apply the render pass to.
  58910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58911. * @param engine The engine which the post process will be applied. (default: current engine)
  58912. * @param reusable If the post process can be reused on the same frame. (default: false)
  58913. * @param textureType Type of textures used when performing the post process. (default: 0)
  58914. * @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)
  58915. */
  58916. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  58917. /** Weight of the bloom to be added to the original input. */
  58918. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58919. }
  58920. }
  58921. declare module BABYLON {
  58922. /**
  58923. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  58924. */
  58925. export class BloomEffect extends PostProcessRenderEffect {
  58926. private bloomScale;
  58927. /**
  58928. * @hidden Internal
  58929. */
  58930. _effects: Array<PostProcess>;
  58931. /**
  58932. * @hidden Internal
  58933. */
  58934. _downscale: ExtractHighlightsPostProcess;
  58935. private _blurX;
  58936. private _blurY;
  58937. private _merge;
  58938. /**
  58939. * The luminance threshold to find bright areas of the image to bloom.
  58940. */
  58941. threshold: number;
  58942. /**
  58943. * The strength of the bloom.
  58944. */
  58945. weight: number;
  58946. /**
  58947. * Specifies the size of the bloom blur kernel, relative to the final output size
  58948. */
  58949. kernel: number;
  58950. /**
  58951. * Creates a new instance of @see BloomEffect
  58952. * @param scene The scene the effect belongs to.
  58953. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58954. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58955. * @param bloomWeight The the strength of bloom.
  58956. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58957. * @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)
  58958. */
  58959. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58960. /**
  58961. * Disposes each of the internal effects for a given camera.
  58962. * @param camera The camera to dispose the effect on.
  58963. */
  58964. disposeEffects(camera: Camera): void;
  58965. /**
  58966. * @hidden Internal
  58967. */
  58968. _updateEffects(): void;
  58969. /**
  58970. * Internal
  58971. * @returns if all the contained post processes are ready.
  58972. * @hidden
  58973. */
  58974. _isReady(): boolean;
  58975. }
  58976. }
  58977. declare module BABYLON {
  58978. /** @hidden */
  58979. export var chromaticAberrationPixelShader: {
  58980. name: string;
  58981. shader: string;
  58982. };
  58983. }
  58984. declare module BABYLON {
  58985. /**
  58986. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58987. */
  58988. export class ChromaticAberrationPostProcess extends PostProcess {
  58989. /**
  58990. * The amount of seperation of rgb channels (default: 30)
  58991. */
  58992. aberrationAmount: number;
  58993. /**
  58994. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58995. */
  58996. radialIntensity: number;
  58997. /**
  58998. * 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))
  58999. */
  59000. direction: Vector2;
  59001. /**
  59002. * 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))
  59003. */
  59004. centerPosition: Vector2;
  59005. /**
  59006. * Creates a new instance ChromaticAberrationPostProcess
  59007. * @param name The name of the effect.
  59008. * @param screenWidth The width of the screen to apply the effect on.
  59009. * @param screenHeight The height of the screen to apply the effect on.
  59010. * @param options The required width/height ratio to downsize to before computing the render pass.
  59011. * @param camera The camera to apply the render pass to.
  59012. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59013. * @param engine The engine which the post process will be applied. (default: current engine)
  59014. * @param reusable If the post process can be reused on the same frame. (default: false)
  59015. * @param textureType Type of textures used when performing the post process. (default: 0)
  59016. * @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)
  59017. */
  59018. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59019. }
  59020. }
  59021. declare module BABYLON {
  59022. /** @hidden */
  59023. export var circleOfConfusionPixelShader: {
  59024. name: string;
  59025. shader: string;
  59026. };
  59027. }
  59028. declare module BABYLON {
  59029. /**
  59030. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59031. */
  59032. export class CircleOfConfusionPostProcess extends PostProcess {
  59033. /**
  59034. * 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.
  59035. */
  59036. lensSize: number;
  59037. /**
  59038. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59039. */
  59040. fStop: number;
  59041. /**
  59042. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59043. */
  59044. focusDistance: number;
  59045. /**
  59046. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59047. */
  59048. focalLength: number;
  59049. private _depthTexture;
  59050. /**
  59051. * Creates a new instance CircleOfConfusionPostProcess
  59052. * @param name The name of the effect.
  59053. * @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.
  59054. * @param options The required width/height ratio to downsize to before computing the render pass.
  59055. * @param camera The camera to apply the render pass to.
  59056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59057. * @param engine The engine which the post process will be applied. (default: current engine)
  59058. * @param reusable If the post process can be reused on the same frame. (default: false)
  59059. * @param textureType Type of textures used when performing the post process. (default: 0)
  59060. * @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)
  59061. */
  59062. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59063. /**
  59064. * 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.
  59065. */
  59066. depthTexture: RenderTargetTexture;
  59067. }
  59068. }
  59069. declare module BABYLON {
  59070. /** @hidden */
  59071. export var colorCorrectionPixelShader: {
  59072. name: string;
  59073. shader: string;
  59074. };
  59075. }
  59076. declare module BABYLON {
  59077. /**
  59078. *
  59079. * This post-process allows the modification of rendered colors by using
  59080. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59081. *
  59082. * The object needs to be provided an url to a texture containing the color
  59083. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59084. * Use an image editing software to tweak the LUT to match your needs.
  59085. *
  59086. * For an example of a color LUT, see here:
  59087. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59088. * For explanations on color grading, see here:
  59089. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59090. *
  59091. */
  59092. export class ColorCorrectionPostProcess extends PostProcess {
  59093. private _colorTableTexture;
  59094. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59095. }
  59096. }
  59097. declare module BABYLON {
  59098. /** @hidden */
  59099. export var convolutionPixelShader: {
  59100. name: string;
  59101. shader: string;
  59102. };
  59103. }
  59104. declare module BABYLON {
  59105. /**
  59106. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59107. * input texture to perform effects such as edge detection or sharpening
  59108. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59109. */
  59110. export class ConvolutionPostProcess extends PostProcess {
  59111. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59112. kernel: number[];
  59113. /**
  59114. * Creates a new instance ConvolutionPostProcess
  59115. * @param name The name of the effect.
  59116. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  59117. * @param options The required width/height ratio to downsize to before computing the render pass.
  59118. * @param camera The camera to apply the render pass to.
  59119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59120. * @param engine The engine which the post process will be applied. (default: current engine)
  59121. * @param reusable If the post process can be reused on the same frame. (default: false)
  59122. * @param textureType Type of textures used when performing the post process. (default: 0)
  59123. */
  59124. constructor(name: string,
  59125. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59126. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59127. /**
  59128. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59129. */
  59130. static EdgeDetect0Kernel: number[];
  59131. /**
  59132. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59133. */
  59134. static EdgeDetect1Kernel: number[];
  59135. /**
  59136. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59137. */
  59138. static EdgeDetect2Kernel: number[];
  59139. /**
  59140. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59141. */
  59142. static SharpenKernel: number[];
  59143. /**
  59144. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59145. */
  59146. static EmbossKernel: number[];
  59147. /**
  59148. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59149. */
  59150. static GaussianKernel: number[];
  59151. }
  59152. }
  59153. declare module BABYLON {
  59154. /**
  59155. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  59156. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  59157. * based on samples that have a large difference in distance than the center pixel.
  59158. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  59159. */
  59160. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  59161. direction: Vector2;
  59162. /**
  59163. * Creates a new instance CircleOfConfusionPostProcess
  59164. * @param name The name of the effect.
  59165. * @param scene The scene the effect belongs to.
  59166. * @param direction The direction the blur should be applied.
  59167. * @param kernel The size of the kernel used to blur.
  59168. * @param options The required width/height ratio to downsize to before computing the render pass.
  59169. * @param camera The camera to apply the render pass to.
  59170. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  59171. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  59172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59173. * @param engine The engine which the post process will be applied. (default: current engine)
  59174. * @param reusable If the post process can be reused on the same frame. (default: false)
  59175. * @param textureType Type of textures used when performing the post process. (default: 0)
  59176. * @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)
  59177. */
  59178. 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);
  59179. }
  59180. }
  59181. declare module BABYLON {
  59182. /** @hidden */
  59183. export var depthOfFieldMergePixelShader: {
  59184. name: string;
  59185. shader: string;
  59186. };
  59187. }
  59188. declare module BABYLON {
  59189. /**
  59190. * Options to be set when merging outputs from the default pipeline.
  59191. */
  59192. export class DepthOfFieldMergePostProcessOptions {
  59193. /**
  59194. * The original image to merge on top of
  59195. */
  59196. originalFromInput: PostProcess;
  59197. /**
  59198. * Parameters to perform the merge of the depth of field effect
  59199. */
  59200. depthOfField?: {
  59201. circleOfConfusion: PostProcess;
  59202. blurSteps: Array<PostProcess>;
  59203. };
  59204. /**
  59205. * Parameters to perform the merge of bloom effect
  59206. */
  59207. bloom?: {
  59208. blurred: PostProcess;
  59209. weight: number;
  59210. };
  59211. }
  59212. /**
  59213. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59214. */
  59215. export class DepthOfFieldMergePostProcess extends PostProcess {
  59216. private blurSteps;
  59217. /**
  59218. * Creates a new instance of DepthOfFieldMergePostProcess
  59219. * @param name The name of the effect.
  59220. * @param originalFromInput Post process which's input will be used for the merge.
  59221. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  59222. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  59223. * @param options The required width/height ratio to downsize to before computing the render pass.
  59224. * @param camera The camera to apply the render pass to.
  59225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59226. * @param engine The engine which the post process will be applied. (default: current engine)
  59227. * @param reusable If the post process can be reused on the same frame. (default: false)
  59228. * @param textureType Type of textures used when performing the post process. (default: 0)
  59229. * @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)
  59230. */
  59231. 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);
  59232. /**
  59233. * Updates the effect with the current post process compile time values and recompiles the shader.
  59234. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  59235. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  59236. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  59237. * @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
  59238. * @param onCompiled Called when the shader has been compiled.
  59239. * @param onError Called if there is an error when compiling a shader.
  59240. */
  59241. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  59242. }
  59243. }
  59244. declare module BABYLON {
  59245. /**
  59246. * Specifies the level of max blur that should be applied when using the depth of field effect
  59247. */
  59248. export enum DepthOfFieldEffectBlurLevel {
  59249. /**
  59250. * Subtle blur
  59251. */
  59252. Low = 0,
  59253. /**
  59254. * Medium blur
  59255. */
  59256. Medium = 1,
  59257. /**
  59258. * Large blur
  59259. */
  59260. High = 2
  59261. }
  59262. /**
  59263. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  59264. */
  59265. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  59266. private _circleOfConfusion;
  59267. /**
  59268. * @hidden Internal, blurs from high to low
  59269. */
  59270. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  59271. private _depthOfFieldBlurY;
  59272. private _dofMerge;
  59273. /**
  59274. * @hidden Internal post processes in depth of field effect
  59275. */
  59276. _effects: Array<PostProcess>;
  59277. /**
  59278. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  59279. */
  59280. focalLength: number;
  59281. /**
  59282. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59283. */
  59284. fStop: number;
  59285. /**
  59286. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59287. */
  59288. focusDistance: number;
  59289. /**
  59290. * 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.
  59291. */
  59292. lensSize: number;
  59293. /**
  59294. * Creates a new instance DepthOfFieldEffect
  59295. * @param scene The scene the effect belongs to.
  59296. * @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.
  59297. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59298. * @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)
  59299. */
  59300. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  59301. /**
  59302. * Get the current class name of the current effet
  59303. * @returns "DepthOfFieldEffect"
  59304. */
  59305. getClassName(): string;
  59306. /**
  59307. * 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.
  59308. */
  59309. depthTexture: RenderTargetTexture;
  59310. /**
  59311. * Disposes each of the internal effects for a given camera.
  59312. * @param camera The camera to dispose the effect on.
  59313. */
  59314. disposeEffects(camera: Camera): void;
  59315. /**
  59316. * @hidden Internal
  59317. */
  59318. _updateEffects(): void;
  59319. /**
  59320. * Internal
  59321. * @returns if all the contained post processes are ready.
  59322. * @hidden
  59323. */
  59324. _isReady(): boolean;
  59325. }
  59326. }
  59327. declare module BABYLON {
  59328. /** @hidden */
  59329. export var displayPassPixelShader: {
  59330. name: string;
  59331. shader: string;
  59332. };
  59333. }
  59334. declare module BABYLON {
  59335. /**
  59336. * DisplayPassPostProcess which produces an output the same as it's input
  59337. */
  59338. export class DisplayPassPostProcess extends PostProcess {
  59339. /**
  59340. * Creates the DisplayPassPostProcess
  59341. * @param name The name of the effect.
  59342. * @param options The required width/height ratio to downsize to before computing the render pass.
  59343. * @param camera The camera to apply the render pass to.
  59344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59345. * @param engine The engine which the post process will be applied. (default: current engine)
  59346. * @param reusable If the post process can be reused on the same frame. (default: false)
  59347. */
  59348. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59349. }
  59350. }
  59351. declare module BABYLON {
  59352. /** @hidden */
  59353. export var filterPixelShader: {
  59354. name: string;
  59355. shader: string;
  59356. };
  59357. }
  59358. declare module BABYLON {
  59359. /**
  59360. * Applies a kernel filter to the image
  59361. */
  59362. export class FilterPostProcess extends PostProcess {
  59363. /** The matrix to be applied to the image */
  59364. kernelMatrix: Matrix;
  59365. /**
  59366. *
  59367. * @param name The name of the effect.
  59368. * @param kernelMatrix The matrix to be applied to the image
  59369. * @param options The required width/height ratio to downsize to before computing the render pass.
  59370. * @param camera The camera to apply the render pass to.
  59371. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59372. * @param engine The engine which the post process will be applied. (default: current engine)
  59373. * @param reusable If the post process can be reused on the same frame. (default: false)
  59374. */
  59375. constructor(name: string,
  59376. /** The matrix to be applied to the image */
  59377. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59378. }
  59379. }
  59380. declare module BABYLON {
  59381. /** @hidden */
  59382. export var fxaaPixelShader: {
  59383. name: string;
  59384. shader: string;
  59385. };
  59386. }
  59387. declare module BABYLON {
  59388. /** @hidden */
  59389. export var fxaaVertexShader: {
  59390. name: string;
  59391. shader: string;
  59392. };
  59393. }
  59394. declare module BABYLON {
  59395. /**
  59396. * Fxaa post process
  59397. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  59398. */
  59399. export class FxaaPostProcess extends PostProcess {
  59400. /** @hidden */
  59401. texelWidth: number;
  59402. /** @hidden */
  59403. texelHeight: number;
  59404. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59405. private _getDefines;
  59406. }
  59407. }
  59408. declare module BABYLON {
  59409. /** @hidden */
  59410. export var grainPixelShader: {
  59411. name: string;
  59412. shader: string;
  59413. };
  59414. }
  59415. declare module BABYLON {
  59416. /**
  59417. * The GrainPostProcess adds noise to the image at mid luminance levels
  59418. */
  59419. export class GrainPostProcess extends PostProcess {
  59420. /**
  59421. * The intensity of the grain added (default: 30)
  59422. */
  59423. intensity: number;
  59424. /**
  59425. * If the grain should be randomized on every frame
  59426. */
  59427. animated: boolean;
  59428. /**
  59429. * Creates a new instance of @see GrainPostProcess
  59430. * @param name The name of the effect.
  59431. * @param options The required width/height ratio to downsize to before computing the render pass.
  59432. * @param camera The camera to apply the render pass to.
  59433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59434. * @param engine The engine which the post process will be applied. (default: current engine)
  59435. * @param reusable If the post process can be reused on the same frame. (default: false)
  59436. * @param textureType Type of textures used when performing the post process. (default: 0)
  59437. * @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)
  59438. */
  59439. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59440. }
  59441. }
  59442. declare module BABYLON {
  59443. /** @hidden */
  59444. export var highlightsPixelShader: {
  59445. name: string;
  59446. shader: string;
  59447. };
  59448. }
  59449. declare module BABYLON {
  59450. /**
  59451. * Extracts highlights from the image
  59452. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59453. */
  59454. export class HighlightsPostProcess extends PostProcess {
  59455. /**
  59456. * Extracts highlights from the image
  59457. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59458. * @param name The name of the effect.
  59459. * @param options The required width/height ratio to downsize to before computing the render pass.
  59460. * @param camera The camera to apply the render pass to.
  59461. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59462. * @param engine The engine which the post process will be applied. (default: current engine)
  59463. * @param reusable If the post process can be reused on the same frame. (default: false)
  59464. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  59465. */
  59466. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59467. }
  59468. }
  59469. declare module BABYLON {
  59470. /** @hidden */
  59471. export var mrtFragmentDeclaration: {
  59472. name: string;
  59473. shader: string;
  59474. };
  59475. }
  59476. declare module BABYLON {
  59477. /** @hidden */
  59478. export var geometryPixelShader: {
  59479. name: string;
  59480. shader: string;
  59481. };
  59482. }
  59483. declare module BABYLON {
  59484. /** @hidden */
  59485. export var geometryVertexShader: {
  59486. name: string;
  59487. shader: string;
  59488. };
  59489. }
  59490. declare module BABYLON {
  59491. /** @hidden */
  59492. interface ISavedTransformationMatrix {
  59493. world: Matrix;
  59494. viewProjection: Matrix;
  59495. }
  59496. /**
  59497. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  59498. */
  59499. export class GeometryBufferRenderer {
  59500. /**
  59501. * Constant used to retrieve the position texture index in the G-Buffer textures array
  59502. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  59503. */
  59504. static readonly POSITION_TEXTURE_TYPE: number;
  59505. /**
  59506. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  59507. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  59508. */
  59509. static readonly VELOCITY_TEXTURE_TYPE: number;
  59510. /**
  59511. * Dictionary used to store the previous transformation matrices of each rendered mesh
  59512. * in order to compute objects velocities when enableVelocity is set to "true"
  59513. * @hidden
  59514. */
  59515. _previousTransformationMatrices: {
  59516. [index: number]: ISavedTransformationMatrix;
  59517. };
  59518. /**
  59519. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  59520. * in order to compute objects velocities when enableVelocity is set to "true"
  59521. * @hidden
  59522. */
  59523. _previousBonesTransformationMatrices: {
  59524. [index: number]: Float32Array;
  59525. };
  59526. /**
  59527. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  59528. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  59529. */
  59530. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  59531. private _scene;
  59532. private _multiRenderTarget;
  59533. private _ratio;
  59534. private _enablePosition;
  59535. private _enableVelocity;
  59536. private _positionIndex;
  59537. private _velocityIndex;
  59538. protected _effect: Effect;
  59539. protected _cachedDefines: string;
  59540. /**
  59541. * Set the render list (meshes to be rendered) used in the G buffer.
  59542. */
  59543. renderList: Mesh[];
  59544. /**
  59545. * Gets wether or not G buffer are supported by the running hardware.
  59546. * This requires draw buffer supports
  59547. */
  59548. readonly isSupported: boolean;
  59549. /**
  59550. * Returns the index of the given texture type in the G-Buffer textures array
  59551. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  59552. * @returns the index of the given texture type in the G-Buffer textures array
  59553. */
  59554. getTextureIndex(textureType: number): number;
  59555. /**
  59556. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  59557. */
  59558. /**
  59559. * Sets whether or not objects positions are enabled for the G buffer.
  59560. */
  59561. enablePosition: boolean;
  59562. /**
  59563. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  59564. */
  59565. /**
  59566. * Sets wether or not objects velocities are enabled for the G buffer.
  59567. */
  59568. enableVelocity: boolean;
  59569. /**
  59570. * Gets the scene associated with the buffer.
  59571. */
  59572. readonly scene: Scene;
  59573. /**
  59574. * Gets the ratio used by the buffer during its creation.
  59575. * How big is the buffer related to the main canvas.
  59576. */
  59577. readonly ratio: number;
  59578. /** @hidden */
  59579. static _SceneComponentInitialization: (scene: Scene) => void;
  59580. /**
  59581. * Creates a new G Buffer for the scene
  59582. * @param scene The scene the buffer belongs to
  59583. * @param ratio How big is the buffer related to the main canvas.
  59584. */
  59585. constructor(scene: Scene, ratio?: number);
  59586. /**
  59587. * Checks wether everything is ready to render a submesh to the G buffer.
  59588. * @param subMesh the submesh to check readiness for
  59589. * @param useInstances is the mesh drawn using instance or not
  59590. * @returns true if ready otherwise false
  59591. */
  59592. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59593. /**
  59594. * Gets the current underlying G Buffer.
  59595. * @returns the buffer
  59596. */
  59597. getGBuffer(): MultiRenderTarget;
  59598. /**
  59599. * Gets the number of samples used to render the buffer (anti aliasing).
  59600. */
  59601. /**
  59602. * Sets the number of samples used to render the buffer (anti aliasing).
  59603. */
  59604. samples: number;
  59605. /**
  59606. * Disposes the renderer and frees up associated resources.
  59607. */
  59608. dispose(): void;
  59609. protected _createRenderTargets(): void;
  59610. private _copyBonesTransformationMatrices;
  59611. }
  59612. }
  59613. declare module BABYLON {
  59614. interface Scene {
  59615. /** @hidden (Backing field) */
  59616. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59617. /**
  59618. * Gets or Sets the current geometry buffer associated to the scene.
  59619. */
  59620. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59621. /**
  59622. * Enables a GeometryBufferRender and associates it with the scene
  59623. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  59624. * @returns the GeometryBufferRenderer
  59625. */
  59626. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  59627. /**
  59628. * Disables the GeometryBufferRender associated with the scene
  59629. */
  59630. disableGeometryBufferRenderer(): void;
  59631. }
  59632. /**
  59633. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  59634. * in several rendering techniques.
  59635. */
  59636. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  59637. /**
  59638. * The component name helpful to identify the component in the list of scene components.
  59639. */
  59640. readonly name: string;
  59641. /**
  59642. * The scene the component belongs to.
  59643. */
  59644. scene: Scene;
  59645. /**
  59646. * Creates a new instance of the component for the given scene
  59647. * @param scene Defines the scene to register the component in
  59648. */
  59649. constructor(scene: Scene);
  59650. /**
  59651. * Registers the component in a given scene
  59652. */
  59653. register(): void;
  59654. /**
  59655. * Rebuilds the elements related to this component in case of
  59656. * context lost for instance.
  59657. */
  59658. rebuild(): void;
  59659. /**
  59660. * Disposes the component and the associated ressources
  59661. */
  59662. dispose(): void;
  59663. private _gatherRenderTargets;
  59664. }
  59665. }
  59666. declare module BABYLON {
  59667. /** @hidden */
  59668. export var motionBlurPixelShader: {
  59669. name: string;
  59670. shader: string;
  59671. };
  59672. }
  59673. declare module BABYLON {
  59674. /**
  59675. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  59676. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  59677. * As an example, all you have to do is to create the post-process:
  59678. * var mb = new BABYLON.MotionBlurPostProcess(
  59679. * 'mb', // The name of the effect.
  59680. * scene, // The scene containing the objects to blur according to their velocity.
  59681. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  59682. * camera // The camera to apply the render pass to.
  59683. * );
  59684. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  59685. */
  59686. export class MotionBlurPostProcess extends PostProcess {
  59687. /**
  59688. * Defines how much the image is blurred by the movement. Default value is equal to 1
  59689. */
  59690. motionStrength: number;
  59691. /**
  59692. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  59693. */
  59694. /**
  59695. * Sets the number of iterations to be used for motion blur quality
  59696. */
  59697. motionBlurSamples: number;
  59698. private _motionBlurSamples;
  59699. private _geometryBufferRenderer;
  59700. /**
  59701. * Creates a new instance MotionBlurPostProcess
  59702. * @param name The name of the effect.
  59703. * @param scene The scene containing the objects to blur according to their velocity.
  59704. * @param options The required width/height ratio to downsize to before computing the render pass.
  59705. * @param camera The camera to apply the render pass to.
  59706. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59707. * @param engine The engine which the post process will be applied. (default: current engine)
  59708. * @param reusable If the post process can be reused on the same frame. (default: false)
  59709. * @param textureType Type of textures used when performing the post process. (default: 0)
  59710. * @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)
  59711. */
  59712. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59713. /**
  59714. * Excludes the given skinned mesh from computing bones velocities.
  59715. * 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.
  59716. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  59717. */
  59718. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59719. /**
  59720. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  59721. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  59722. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  59723. */
  59724. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59725. /**
  59726. * Disposes the post process.
  59727. * @param camera The camera to dispose the post process on.
  59728. */
  59729. dispose(camera?: Camera): void;
  59730. }
  59731. }
  59732. declare module BABYLON {
  59733. /** @hidden */
  59734. export var refractionPixelShader: {
  59735. name: string;
  59736. shader: string;
  59737. };
  59738. }
  59739. declare module BABYLON {
  59740. /**
  59741. * Post process which applies a refractin texture
  59742. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59743. */
  59744. export class RefractionPostProcess extends PostProcess {
  59745. /** the base color of the refraction (used to taint the rendering) */
  59746. color: Color3;
  59747. /** simulated refraction depth */
  59748. depth: number;
  59749. /** the coefficient of the base color (0 to remove base color tainting) */
  59750. colorLevel: number;
  59751. private _refTexture;
  59752. private _ownRefractionTexture;
  59753. /**
  59754. * Gets or sets the refraction texture
  59755. * Please note that you are responsible for disposing the texture if you set it manually
  59756. */
  59757. refractionTexture: Texture;
  59758. /**
  59759. * Initializes the RefractionPostProcess
  59760. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59761. * @param name The name of the effect.
  59762. * @param refractionTextureUrl Url of the refraction texture to use
  59763. * @param color the base color of the refraction (used to taint the rendering)
  59764. * @param depth simulated refraction depth
  59765. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  59766. * @param camera The camera to apply the render pass to.
  59767. * @param options The required width/height ratio to downsize to before computing the render pass.
  59768. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59769. * @param engine The engine which the post process will be applied. (default: current engine)
  59770. * @param reusable If the post process can be reused on the same frame. (default: false)
  59771. */
  59772. constructor(name: string, refractionTextureUrl: string,
  59773. /** the base color of the refraction (used to taint the rendering) */
  59774. color: Color3,
  59775. /** simulated refraction depth */
  59776. depth: number,
  59777. /** the coefficient of the base color (0 to remove base color tainting) */
  59778. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59779. /**
  59780. * Disposes of the post process
  59781. * @param camera Camera to dispose post process on
  59782. */
  59783. dispose(camera: Camera): void;
  59784. }
  59785. }
  59786. declare module BABYLON {
  59787. /** @hidden */
  59788. export var sharpenPixelShader: {
  59789. name: string;
  59790. shader: string;
  59791. };
  59792. }
  59793. declare module BABYLON {
  59794. /**
  59795. * The SharpenPostProcess applies a sharpen kernel to every pixel
  59796. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59797. */
  59798. export class SharpenPostProcess extends PostProcess {
  59799. /**
  59800. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  59801. */
  59802. colorAmount: number;
  59803. /**
  59804. * How much sharpness should be applied (default: 0.3)
  59805. */
  59806. edgeAmount: number;
  59807. /**
  59808. * Creates a new instance ConvolutionPostProcess
  59809. * @param name The name of the effect.
  59810. * @param options The required width/height ratio to downsize to before computing the render pass.
  59811. * @param camera The camera to apply the render pass to.
  59812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59813. * @param engine The engine which the post process will be applied. (default: current engine)
  59814. * @param reusable If the post process can be reused on the same frame. (default: false)
  59815. * @param textureType Type of textures used when performing the post process. (default: 0)
  59816. * @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)
  59817. */
  59818. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59819. }
  59820. }
  59821. declare module BABYLON {
  59822. /**
  59823. * PostProcessRenderPipeline
  59824. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59825. */
  59826. export class PostProcessRenderPipeline {
  59827. private engine;
  59828. private _renderEffects;
  59829. private _renderEffectsForIsolatedPass;
  59830. /**
  59831. * List of inspectable custom properties (used by the Inspector)
  59832. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  59833. */
  59834. inspectableCustomProperties: IInspectable[];
  59835. /**
  59836. * @hidden
  59837. */
  59838. protected _cameras: Camera[];
  59839. /** @hidden */
  59840. _name: string;
  59841. /**
  59842. * Gets pipeline name
  59843. */
  59844. readonly name: string;
  59845. /**
  59846. * Initializes a PostProcessRenderPipeline
  59847. * @param engine engine to add the pipeline to
  59848. * @param name name of the pipeline
  59849. */
  59850. constructor(engine: Engine, name: string);
  59851. /**
  59852. * Gets the class name
  59853. * @returns "PostProcessRenderPipeline"
  59854. */
  59855. getClassName(): string;
  59856. /**
  59857. * If all the render effects in the pipeline are supported
  59858. */
  59859. readonly isSupported: boolean;
  59860. /**
  59861. * Adds an effect to the pipeline
  59862. * @param renderEffect the effect to add
  59863. */
  59864. addEffect(renderEffect: PostProcessRenderEffect): void;
  59865. /** @hidden */
  59866. _rebuild(): void;
  59867. /** @hidden */
  59868. _enableEffect(renderEffectName: string, cameras: Camera): void;
  59869. /** @hidden */
  59870. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  59871. /** @hidden */
  59872. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59873. /** @hidden */
  59874. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59875. /** @hidden */
  59876. _attachCameras(cameras: Camera, unique: boolean): void;
  59877. /** @hidden */
  59878. _attachCameras(cameras: Camera[], unique: boolean): void;
  59879. /** @hidden */
  59880. _detachCameras(cameras: Camera): void;
  59881. /** @hidden */
  59882. _detachCameras(cameras: Nullable<Camera[]>): void;
  59883. /** @hidden */
  59884. _update(): void;
  59885. /** @hidden */
  59886. _reset(): void;
  59887. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59888. /**
  59889. * Disposes of the pipeline
  59890. */
  59891. dispose(): void;
  59892. }
  59893. }
  59894. declare module BABYLON {
  59895. /**
  59896. * PostProcessRenderPipelineManager class
  59897. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59898. */
  59899. export class PostProcessRenderPipelineManager {
  59900. private _renderPipelines;
  59901. /**
  59902. * Initializes a PostProcessRenderPipelineManager
  59903. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59904. */
  59905. constructor();
  59906. /**
  59907. * Gets the list of supported render pipelines
  59908. */
  59909. readonly supportedPipelines: PostProcessRenderPipeline[];
  59910. /**
  59911. * Adds a pipeline to the manager
  59912. * @param renderPipeline The pipeline to add
  59913. */
  59914. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59915. /**
  59916. * Attaches a camera to the pipeline
  59917. * @param renderPipelineName The name of the pipeline to attach to
  59918. * @param cameras the camera to attach
  59919. * @param unique if the camera can be attached multiple times to the pipeline
  59920. */
  59921. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59922. /**
  59923. * Detaches a camera from the pipeline
  59924. * @param renderPipelineName The name of the pipeline to detach from
  59925. * @param cameras the camera to detach
  59926. */
  59927. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59928. /**
  59929. * Enables an effect by name on a pipeline
  59930. * @param renderPipelineName the name of the pipeline to enable the effect in
  59931. * @param renderEffectName the name of the effect to enable
  59932. * @param cameras the cameras that the effect should be enabled on
  59933. */
  59934. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59935. /**
  59936. * Disables an effect by name on a pipeline
  59937. * @param renderPipelineName the name of the pipeline to disable the effect in
  59938. * @param renderEffectName the name of the effect to disable
  59939. * @param cameras the cameras that the effect should be disabled on
  59940. */
  59941. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59942. /**
  59943. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59944. */
  59945. update(): void;
  59946. /** @hidden */
  59947. _rebuild(): void;
  59948. /**
  59949. * Disposes of the manager and pipelines
  59950. */
  59951. dispose(): void;
  59952. }
  59953. }
  59954. declare module BABYLON {
  59955. interface Scene {
  59956. /** @hidden (Backing field) */
  59957. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59958. /**
  59959. * Gets the postprocess render pipeline manager
  59960. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59961. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59962. */
  59963. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59964. }
  59965. /**
  59966. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59967. */
  59968. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59969. /**
  59970. * The component name helpfull to identify the component in the list of scene components.
  59971. */
  59972. readonly name: string;
  59973. /**
  59974. * The scene the component belongs to.
  59975. */
  59976. scene: Scene;
  59977. /**
  59978. * Creates a new instance of the component for the given scene
  59979. * @param scene Defines the scene to register the component in
  59980. */
  59981. constructor(scene: Scene);
  59982. /**
  59983. * Registers the component in a given scene
  59984. */
  59985. register(): void;
  59986. /**
  59987. * Rebuilds the elements related to this component in case of
  59988. * context lost for instance.
  59989. */
  59990. rebuild(): void;
  59991. /**
  59992. * Disposes the component and the associated ressources
  59993. */
  59994. dispose(): void;
  59995. private _gatherRenderTargets;
  59996. }
  59997. }
  59998. declare module BABYLON {
  59999. /**
  60000. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  60001. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60002. */
  60003. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60004. private _scene;
  60005. private _camerasToBeAttached;
  60006. /**
  60007. * ID of the sharpen post process,
  60008. */
  60009. private readonly SharpenPostProcessId;
  60010. /**
  60011. * @ignore
  60012. * ID of the image processing post process;
  60013. */
  60014. readonly ImageProcessingPostProcessId: string;
  60015. /**
  60016. * @ignore
  60017. * ID of the Fast Approximate Anti-Aliasing post process;
  60018. */
  60019. readonly FxaaPostProcessId: string;
  60020. /**
  60021. * ID of the chromatic aberration post process,
  60022. */
  60023. private readonly ChromaticAberrationPostProcessId;
  60024. /**
  60025. * ID of the grain post process
  60026. */
  60027. private readonly GrainPostProcessId;
  60028. /**
  60029. * Sharpen post process which will apply a sharpen convolution to enhance edges
  60030. */
  60031. sharpen: SharpenPostProcess;
  60032. private _sharpenEffect;
  60033. private bloom;
  60034. /**
  60035. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  60036. */
  60037. depthOfField: DepthOfFieldEffect;
  60038. /**
  60039. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60040. */
  60041. fxaa: FxaaPostProcess;
  60042. /**
  60043. * Image post processing pass used to perform operations such as tone mapping or color grading.
  60044. */
  60045. imageProcessing: ImageProcessingPostProcess;
  60046. /**
  60047. * Chromatic aberration post process which will shift rgb colors in the image
  60048. */
  60049. chromaticAberration: ChromaticAberrationPostProcess;
  60050. private _chromaticAberrationEffect;
  60051. /**
  60052. * Grain post process which add noise to the image
  60053. */
  60054. grain: GrainPostProcess;
  60055. private _grainEffect;
  60056. /**
  60057. * Glow post process which adds a glow to emissive areas of the image
  60058. */
  60059. private _glowLayer;
  60060. /**
  60061. * Animations which can be used to tweak settings over a period of time
  60062. */
  60063. animations: Animation[];
  60064. private _imageProcessingConfigurationObserver;
  60065. private _sharpenEnabled;
  60066. private _bloomEnabled;
  60067. private _depthOfFieldEnabled;
  60068. private _depthOfFieldBlurLevel;
  60069. private _fxaaEnabled;
  60070. private _imageProcessingEnabled;
  60071. private _defaultPipelineTextureType;
  60072. private _bloomScale;
  60073. private _chromaticAberrationEnabled;
  60074. private _grainEnabled;
  60075. private _buildAllowed;
  60076. /**
  60077. * Gets active scene
  60078. */
  60079. readonly scene: Scene;
  60080. /**
  60081. * Enable or disable the sharpen process from the pipeline
  60082. */
  60083. sharpenEnabled: boolean;
  60084. private _resizeObserver;
  60085. private _hardwareScaleLevel;
  60086. private _bloomKernel;
  60087. /**
  60088. * Specifies the size of the bloom blur kernel, relative to the final output size
  60089. */
  60090. bloomKernel: number;
  60091. /**
  60092. * Specifies the weight of the bloom in the final rendering
  60093. */
  60094. private _bloomWeight;
  60095. /**
  60096. * Specifies the luma threshold for the area that will be blurred by the bloom
  60097. */
  60098. private _bloomThreshold;
  60099. private _hdr;
  60100. /**
  60101. * The strength of the bloom.
  60102. */
  60103. bloomWeight: number;
  60104. /**
  60105. * The strength of the bloom.
  60106. */
  60107. bloomThreshold: number;
  60108. /**
  60109. * The scale of the bloom, lower value will provide better performance.
  60110. */
  60111. bloomScale: number;
  60112. /**
  60113. * Enable or disable the bloom from the pipeline
  60114. */
  60115. bloomEnabled: boolean;
  60116. private _rebuildBloom;
  60117. /**
  60118. * If the depth of field is enabled.
  60119. */
  60120. depthOfFieldEnabled: boolean;
  60121. /**
  60122. * Blur level of the depth of field effect. (Higher blur will effect performance)
  60123. */
  60124. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  60125. /**
  60126. * If the anti aliasing is enabled.
  60127. */
  60128. fxaaEnabled: boolean;
  60129. private _samples;
  60130. /**
  60131. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60132. */
  60133. samples: number;
  60134. /**
  60135. * If image processing is enabled.
  60136. */
  60137. imageProcessingEnabled: boolean;
  60138. /**
  60139. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  60140. */
  60141. glowLayerEnabled: boolean;
  60142. /**
  60143. * Gets the glow layer (or null if not defined)
  60144. */
  60145. readonly glowLayer: Nullable<GlowLayer>;
  60146. /**
  60147. * Enable or disable the chromaticAberration process from the pipeline
  60148. */
  60149. chromaticAberrationEnabled: boolean;
  60150. /**
  60151. * Enable or disable the grain process from the pipeline
  60152. */
  60153. grainEnabled: boolean;
  60154. /**
  60155. * @constructor
  60156. * @param name - The rendering pipeline name (default: "")
  60157. * @param hdr - If high dynamic range textures should be used (default: true)
  60158. * @param scene - The scene linked to this pipeline (default: the last created scene)
  60159. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  60160. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  60161. */
  60162. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  60163. /**
  60164. * Get the class name
  60165. * @returns "DefaultRenderingPipeline"
  60166. */
  60167. getClassName(): string;
  60168. /**
  60169. * Force the compilation of the entire pipeline.
  60170. */
  60171. prepare(): void;
  60172. private _hasCleared;
  60173. private _prevPostProcess;
  60174. private _prevPrevPostProcess;
  60175. private _setAutoClearAndTextureSharing;
  60176. private _depthOfFieldSceneObserver;
  60177. private _buildPipeline;
  60178. private _disposePostProcesses;
  60179. /**
  60180. * Adds a camera to the pipeline
  60181. * @param camera the camera to be added
  60182. */
  60183. addCamera(camera: Camera): void;
  60184. /**
  60185. * Removes a camera from the pipeline
  60186. * @param camera the camera to remove
  60187. */
  60188. removeCamera(camera: Camera): void;
  60189. /**
  60190. * Dispose of the pipeline and stop all post processes
  60191. */
  60192. dispose(): void;
  60193. /**
  60194. * Serialize the rendering pipeline (Used when exporting)
  60195. * @returns the serialized object
  60196. */
  60197. serialize(): any;
  60198. /**
  60199. * Parse the serialized pipeline
  60200. * @param source Source pipeline.
  60201. * @param scene The scene to load the pipeline to.
  60202. * @param rootUrl The URL of the serialized pipeline.
  60203. * @returns An instantiated pipeline from the serialized object.
  60204. */
  60205. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  60206. }
  60207. }
  60208. declare module BABYLON {
  60209. /** @hidden */
  60210. export var lensHighlightsPixelShader: {
  60211. name: string;
  60212. shader: string;
  60213. };
  60214. }
  60215. declare module BABYLON {
  60216. /** @hidden */
  60217. export var depthOfFieldPixelShader: {
  60218. name: string;
  60219. shader: string;
  60220. };
  60221. }
  60222. declare module BABYLON {
  60223. /**
  60224. * BABYLON.JS Chromatic Aberration GLSL Shader
  60225. * Author: Olivier Guyot
  60226. * Separates very slightly R, G and B colors on the edges of the screen
  60227. * Inspired by Francois Tarlier & Martins Upitis
  60228. */
  60229. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  60230. /**
  60231. * @ignore
  60232. * The chromatic aberration PostProcess id in the pipeline
  60233. */
  60234. LensChromaticAberrationEffect: string;
  60235. /**
  60236. * @ignore
  60237. * The highlights enhancing PostProcess id in the pipeline
  60238. */
  60239. HighlightsEnhancingEffect: string;
  60240. /**
  60241. * @ignore
  60242. * The depth-of-field PostProcess id in the pipeline
  60243. */
  60244. LensDepthOfFieldEffect: string;
  60245. private _scene;
  60246. private _depthTexture;
  60247. private _grainTexture;
  60248. private _chromaticAberrationPostProcess;
  60249. private _highlightsPostProcess;
  60250. private _depthOfFieldPostProcess;
  60251. private _edgeBlur;
  60252. private _grainAmount;
  60253. private _chromaticAberration;
  60254. private _distortion;
  60255. private _highlightsGain;
  60256. private _highlightsThreshold;
  60257. private _dofDistance;
  60258. private _dofAperture;
  60259. private _dofDarken;
  60260. private _dofPentagon;
  60261. private _blurNoise;
  60262. /**
  60263. * @constructor
  60264. *
  60265. * Effect parameters are as follow:
  60266. * {
  60267. * chromatic_aberration: number; // from 0 to x (1 for realism)
  60268. * edge_blur: number; // from 0 to x (1 for realism)
  60269. * distortion: number; // from 0 to x (1 for realism)
  60270. * grain_amount: number; // from 0 to 1
  60271. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  60272. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  60273. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  60274. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  60275. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  60276. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  60277. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  60278. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  60279. * }
  60280. * Note: if an effect parameter is unset, effect is disabled
  60281. *
  60282. * @param name The rendering pipeline name
  60283. * @param parameters - An object containing all parameters (see above)
  60284. * @param scene The scene linked to this pipeline
  60285. * @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)
  60286. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60287. */
  60288. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  60289. /**
  60290. * Get the class name
  60291. * @returns "LensRenderingPipeline"
  60292. */
  60293. getClassName(): string;
  60294. /**
  60295. * Gets associated scene
  60296. */
  60297. readonly scene: Scene;
  60298. /**
  60299. * Gets or sets the edge blur
  60300. */
  60301. edgeBlur: number;
  60302. /**
  60303. * Gets or sets the grain amount
  60304. */
  60305. grainAmount: number;
  60306. /**
  60307. * Gets or sets the chromatic aberration amount
  60308. */
  60309. chromaticAberration: number;
  60310. /**
  60311. * Gets or sets the depth of field aperture
  60312. */
  60313. dofAperture: number;
  60314. /**
  60315. * Gets or sets the edge distortion
  60316. */
  60317. edgeDistortion: number;
  60318. /**
  60319. * Gets or sets the depth of field distortion
  60320. */
  60321. dofDistortion: number;
  60322. /**
  60323. * Gets or sets the darken out of focus amount
  60324. */
  60325. darkenOutOfFocus: number;
  60326. /**
  60327. * Gets or sets a boolean indicating if blur noise is enabled
  60328. */
  60329. blurNoise: boolean;
  60330. /**
  60331. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  60332. */
  60333. pentagonBokeh: boolean;
  60334. /**
  60335. * Gets or sets the highlight grain amount
  60336. */
  60337. highlightsGain: number;
  60338. /**
  60339. * Gets or sets the highlight threshold
  60340. */
  60341. highlightsThreshold: number;
  60342. /**
  60343. * Sets the amount of blur at the edges
  60344. * @param amount blur amount
  60345. */
  60346. setEdgeBlur(amount: number): void;
  60347. /**
  60348. * Sets edge blur to 0
  60349. */
  60350. disableEdgeBlur(): void;
  60351. /**
  60352. * Sets the amout of grain
  60353. * @param amount Amount of grain
  60354. */
  60355. setGrainAmount(amount: number): void;
  60356. /**
  60357. * Set grain amount to 0
  60358. */
  60359. disableGrain(): void;
  60360. /**
  60361. * Sets the chromatic aberration amount
  60362. * @param amount amount of chromatic aberration
  60363. */
  60364. setChromaticAberration(amount: number): void;
  60365. /**
  60366. * Sets chromatic aberration amount to 0
  60367. */
  60368. disableChromaticAberration(): void;
  60369. /**
  60370. * Sets the EdgeDistortion amount
  60371. * @param amount amount of EdgeDistortion
  60372. */
  60373. setEdgeDistortion(amount: number): void;
  60374. /**
  60375. * Sets edge distortion to 0
  60376. */
  60377. disableEdgeDistortion(): void;
  60378. /**
  60379. * Sets the FocusDistance amount
  60380. * @param amount amount of FocusDistance
  60381. */
  60382. setFocusDistance(amount: number): void;
  60383. /**
  60384. * Disables depth of field
  60385. */
  60386. disableDepthOfField(): void;
  60387. /**
  60388. * Sets the Aperture amount
  60389. * @param amount amount of Aperture
  60390. */
  60391. setAperture(amount: number): void;
  60392. /**
  60393. * Sets the DarkenOutOfFocus amount
  60394. * @param amount amount of DarkenOutOfFocus
  60395. */
  60396. setDarkenOutOfFocus(amount: number): void;
  60397. private _pentagonBokehIsEnabled;
  60398. /**
  60399. * Creates a pentagon bokeh effect
  60400. */
  60401. enablePentagonBokeh(): void;
  60402. /**
  60403. * Disables the pentagon bokeh effect
  60404. */
  60405. disablePentagonBokeh(): void;
  60406. /**
  60407. * Enables noise blur
  60408. */
  60409. enableNoiseBlur(): void;
  60410. /**
  60411. * Disables noise blur
  60412. */
  60413. disableNoiseBlur(): void;
  60414. /**
  60415. * Sets the HighlightsGain amount
  60416. * @param amount amount of HighlightsGain
  60417. */
  60418. setHighlightsGain(amount: number): void;
  60419. /**
  60420. * Sets the HighlightsThreshold amount
  60421. * @param amount amount of HighlightsThreshold
  60422. */
  60423. setHighlightsThreshold(amount: number): void;
  60424. /**
  60425. * Disables highlights
  60426. */
  60427. disableHighlights(): void;
  60428. /**
  60429. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  60430. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  60431. */
  60432. dispose(disableDepthRender?: boolean): void;
  60433. private _createChromaticAberrationPostProcess;
  60434. private _createHighlightsPostProcess;
  60435. private _createDepthOfFieldPostProcess;
  60436. private _createGrainTexture;
  60437. }
  60438. }
  60439. declare module BABYLON {
  60440. /** @hidden */
  60441. export var ssao2PixelShader: {
  60442. name: string;
  60443. shader: string;
  60444. };
  60445. }
  60446. declare module BABYLON {
  60447. /** @hidden */
  60448. export var ssaoCombinePixelShader: {
  60449. name: string;
  60450. shader: string;
  60451. };
  60452. }
  60453. declare module BABYLON {
  60454. /**
  60455. * Render pipeline to produce ssao effect
  60456. */
  60457. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  60458. /**
  60459. * @ignore
  60460. * The PassPostProcess id in the pipeline that contains the original scene color
  60461. */
  60462. SSAOOriginalSceneColorEffect: string;
  60463. /**
  60464. * @ignore
  60465. * The SSAO PostProcess id in the pipeline
  60466. */
  60467. SSAORenderEffect: string;
  60468. /**
  60469. * @ignore
  60470. * The horizontal blur PostProcess id in the pipeline
  60471. */
  60472. SSAOBlurHRenderEffect: string;
  60473. /**
  60474. * @ignore
  60475. * The vertical blur PostProcess id in the pipeline
  60476. */
  60477. SSAOBlurVRenderEffect: string;
  60478. /**
  60479. * @ignore
  60480. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60481. */
  60482. SSAOCombineRenderEffect: string;
  60483. /**
  60484. * The output strength of the SSAO post-process. Default value is 1.0.
  60485. */
  60486. totalStrength: number;
  60487. /**
  60488. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  60489. */
  60490. maxZ: number;
  60491. /**
  60492. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  60493. */
  60494. minZAspect: number;
  60495. private _samples;
  60496. /**
  60497. * Number of samples used for the SSAO calculations. Default value is 8
  60498. */
  60499. samples: number;
  60500. private _textureSamples;
  60501. /**
  60502. * Number of samples to use for antialiasing
  60503. */
  60504. textureSamples: number;
  60505. /**
  60506. * Ratio object used for SSAO ratio and blur ratio
  60507. */
  60508. private _ratio;
  60509. /**
  60510. * Dynamically generated sphere sampler.
  60511. */
  60512. private _sampleSphere;
  60513. /**
  60514. * Blur filter offsets
  60515. */
  60516. private _samplerOffsets;
  60517. private _expensiveBlur;
  60518. /**
  60519. * If bilateral blur should be used
  60520. */
  60521. expensiveBlur: boolean;
  60522. /**
  60523. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  60524. */
  60525. radius: number;
  60526. /**
  60527. * The base color of the SSAO post-process
  60528. * The final result is "base + ssao" between [0, 1]
  60529. */
  60530. base: number;
  60531. /**
  60532. * Support test.
  60533. */
  60534. static readonly IsSupported: boolean;
  60535. private _scene;
  60536. private _depthTexture;
  60537. private _normalTexture;
  60538. private _randomTexture;
  60539. private _originalColorPostProcess;
  60540. private _ssaoPostProcess;
  60541. private _blurHPostProcess;
  60542. private _blurVPostProcess;
  60543. private _ssaoCombinePostProcess;
  60544. private _firstUpdate;
  60545. /**
  60546. * Gets active scene
  60547. */
  60548. readonly scene: Scene;
  60549. /**
  60550. * @constructor
  60551. * @param name The rendering pipeline name
  60552. * @param scene The scene linked to this pipeline
  60553. * @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 }
  60554. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60555. */
  60556. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60557. /**
  60558. * Get the class name
  60559. * @returns "SSAO2RenderingPipeline"
  60560. */
  60561. getClassName(): string;
  60562. /**
  60563. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60564. */
  60565. dispose(disableGeometryBufferRenderer?: boolean): void;
  60566. private _createBlurPostProcess;
  60567. /** @hidden */
  60568. _rebuild(): void;
  60569. private _bits;
  60570. private _radicalInverse_VdC;
  60571. private _hammersley;
  60572. private _hemisphereSample_uniform;
  60573. private _generateHemisphere;
  60574. private _createSSAOPostProcess;
  60575. private _createSSAOCombinePostProcess;
  60576. private _createRandomTexture;
  60577. /**
  60578. * Serialize the rendering pipeline (Used when exporting)
  60579. * @returns the serialized object
  60580. */
  60581. serialize(): any;
  60582. /**
  60583. * Parse the serialized pipeline
  60584. * @param source Source pipeline.
  60585. * @param scene The scene to load the pipeline to.
  60586. * @param rootUrl The URL of the serialized pipeline.
  60587. * @returns An instantiated pipeline from the serialized object.
  60588. */
  60589. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  60590. }
  60591. }
  60592. declare module BABYLON {
  60593. /** @hidden */
  60594. export var ssaoPixelShader: {
  60595. name: string;
  60596. shader: string;
  60597. };
  60598. }
  60599. declare module BABYLON {
  60600. /**
  60601. * Render pipeline to produce ssao effect
  60602. */
  60603. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  60604. /**
  60605. * @ignore
  60606. * The PassPostProcess id in the pipeline that contains the original scene color
  60607. */
  60608. SSAOOriginalSceneColorEffect: string;
  60609. /**
  60610. * @ignore
  60611. * The SSAO PostProcess id in the pipeline
  60612. */
  60613. SSAORenderEffect: string;
  60614. /**
  60615. * @ignore
  60616. * The horizontal blur PostProcess id in the pipeline
  60617. */
  60618. SSAOBlurHRenderEffect: string;
  60619. /**
  60620. * @ignore
  60621. * The vertical blur PostProcess id in the pipeline
  60622. */
  60623. SSAOBlurVRenderEffect: string;
  60624. /**
  60625. * @ignore
  60626. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60627. */
  60628. SSAOCombineRenderEffect: string;
  60629. /**
  60630. * The output strength of the SSAO post-process. Default value is 1.0.
  60631. */
  60632. totalStrength: number;
  60633. /**
  60634. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  60635. */
  60636. radius: number;
  60637. /**
  60638. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  60639. * Must not be equal to fallOff and superior to fallOff.
  60640. * Default value is 0.0075
  60641. */
  60642. area: number;
  60643. /**
  60644. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  60645. * Must not be equal to area and inferior to area.
  60646. * Default value is 0.000001
  60647. */
  60648. fallOff: number;
  60649. /**
  60650. * The base color of the SSAO post-process
  60651. * The final result is "base + ssao" between [0, 1]
  60652. */
  60653. base: number;
  60654. private _scene;
  60655. private _depthTexture;
  60656. private _randomTexture;
  60657. private _originalColorPostProcess;
  60658. private _ssaoPostProcess;
  60659. private _blurHPostProcess;
  60660. private _blurVPostProcess;
  60661. private _ssaoCombinePostProcess;
  60662. private _firstUpdate;
  60663. /**
  60664. * Gets active scene
  60665. */
  60666. readonly scene: Scene;
  60667. /**
  60668. * @constructor
  60669. * @param name - The rendering pipeline name
  60670. * @param scene - The scene linked to this pipeline
  60671. * @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 }
  60672. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  60673. */
  60674. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60675. /**
  60676. * Get the class name
  60677. * @returns "SSAORenderingPipeline"
  60678. */
  60679. getClassName(): string;
  60680. /**
  60681. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60682. */
  60683. dispose(disableDepthRender?: boolean): void;
  60684. private _createBlurPostProcess;
  60685. /** @hidden */
  60686. _rebuild(): void;
  60687. private _createSSAOPostProcess;
  60688. private _createSSAOCombinePostProcess;
  60689. private _createRandomTexture;
  60690. }
  60691. }
  60692. declare module BABYLON {
  60693. /** @hidden */
  60694. export var standardPixelShader: {
  60695. name: string;
  60696. shader: string;
  60697. };
  60698. }
  60699. declare module BABYLON {
  60700. /**
  60701. * Standard rendering pipeline
  60702. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60703. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  60704. */
  60705. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60706. /**
  60707. * Public members
  60708. */
  60709. /**
  60710. * Post-process which contains the original scene color before the pipeline applies all the effects
  60711. */
  60712. originalPostProcess: Nullable<PostProcess>;
  60713. /**
  60714. * Post-process used to down scale an image x4
  60715. */
  60716. downSampleX4PostProcess: Nullable<PostProcess>;
  60717. /**
  60718. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  60719. */
  60720. brightPassPostProcess: Nullable<PostProcess>;
  60721. /**
  60722. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  60723. */
  60724. blurHPostProcesses: PostProcess[];
  60725. /**
  60726. * Post-process array storing all the vertical blur post-processes used by the pipeline
  60727. */
  60728. blurVPostProcesses: PostProcess[];
  60729. /**
  60730. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  60731. */
  60732. textureAdderPostProcess: Nullable<PostProcess>;
  60733. /**
  60734. * Post-process used to create volumetric lighting effect
  60735. */
  60736. volumetricLightPostProcess: Nullable<PostProcess>;
  60737. /**
  60738. * Post-process used to smooth the previous volumetric light post-process on the X axis
  60739. */
  60740. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  60741. /**
  60742. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  60743. */
  60744. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  60745. /**
  60746. * Post-process used to merge the volumetric light effect and the real scene color
  60747. */
  60748. volumetricLightMergePostProces: Nullable<PostProcess>;
  60749. /**
  60750. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  60751. */
  60752. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  60753. /**
  60754. * Base post-process used to calculate the average luminance of the final image for HDR
  60755. */
  60756. luminancePostProcess: Nullable<PostProcess>;
  60757. /**
  60758. * Post-processes used to create down sample post-processes in order to get
  60759. * the average luminance of the final image for HDR
  60760. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  60761. */
  60762. luminanceDownSamplePostProcesses: PostProcess[];
  60763. /**
  60764. * Post-process used to create a HDR effect (light adaptation)
  60765. */
  60766. hdrPostProcess: Nullable<PostProcess>;
  60767. /**
  60768. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  60769. */
  60770. textureAdderFinalPostProcess: Nullable<PostProcess>;
  60771. /**
  60772. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  60773. */
  60774. lensFlareFinalPostProcess: Nullable<PostProcess>;
  60775. /**
  60776. * Post-process used to merge the final HDR post-process and the real scene color
  60777. */
  60778. hdrFinalPostProcess: Nullable<PostProcess>;
  60779. /**
  60780. * Post-process used to create a lens flare effect
  60781. */
  60782. lensFlarePostProcess: Nullable<PostProcess>;
  60783. /**
  60784. * Post-process that merges the result of the lens flare post-process and the real scene color
  60785. */
  60786. lensFlareComposePostProcess: Nullable<PostProcess>;
  60787. /**
  60788. * Post-process used to create a motion blur effect
  60789. */
  60790. motionBlurPostProcess: Nullable<PostProcess>;
  60791. /**
  60792. * Post-process used to create a depth of field effect
  60793. */
  60794. depthOfFieldPostProcess: Nullable<PostProcess>;
  60795. /**
  60796. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60797. */
  60798. fxaaPostProcess: Nullable<FxaaPostProcess>;
  60799. /**
  60800. * Represents the brightness threshold in order to configure the illuminated surfaces
  60801. */
  60802. brightThreshold: number;
  60803. /**
  60804. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  60805. */
  60806. blurWidth: number;
  60807. /**
  60808. * Sets if the blur for highlighted surfaces must be only horizontal
  60809. */
  60810. horizontalBlur: boolean;
  60811. /**
  60812. * Gets the overall exposure used by the pipeline
  60813. */
  60814. /**
  60815. * Sets the overall exposure used by the pipeline
  60816. */
  60817. exposure: number;
  60818. /**
  60819. * Texture used typically to simulate "dirty" on camera lens
  60820. */
  60821. lensTexture: Nullable<Texture>;
  60822. /**
  60823. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  60824. */
  60825. volumetricLightCoefficient: number;
  60826. /**
  60827. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  60828. */
  60829. volumetricLightPower: number;
  60830. /**
  60831. * Used the set the blur intensity to smooth the volumetric lights
  60832. */
  60833. volumetricLightBlurScale: number;
  60834. /**
  60835. * Light (spot or directional) used to generate the volumetric lights rays
  60836. * The source light must have a shadow generate so the pipeline can get its
  60837. * depth map
  60838. */
  60839. sourceLight: Nullable<SpotLight | DirectionalLight>;
  60840. /**
  60841. * For eye adaptation, represents the minimum luminance the eye can see
  60842. */
  60843. hdrMinimumLuminance: number;
  60844. /**
  60845. * For eye adaptation, represents the decrease luminance speed
  60846. */
  60847. hdrDecreaseRate: number;
  60848. /**
  60849. * For eye adaptation, represents the increase luminance speed
  60850. */
  60851. hdrIncreaseRate: number;
  60852. /**
  60853. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60854. */
  60855. /**
  60856. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60857. */
  60858. hdrAutoExposure: boolean;
  60859. /**
  60860. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  60861. */
  60862. lensColorTexture: Nullable<Texture>;
  60863. /**
  60864. * The overall strengh for the lens flare effect
  60865. */
  60866. lensFlareStrength: number;
  60867. /**
  60868. * Dispersion coefficient for lens flare ghosts
  60869. */
  60870. lensFlareGhostDispersal: number;
  60871. /**
  60872. * Main lens flare halo width
  60873. */
  60874. lensFlareHaloWidth: number;
  60875. /**
  60876. * Based on the lens distortion effect, defines how much the lens flare result
  60877. * is distorted
  60878. */
  60879. lensFlareDistortionStrength: number;
  60880. /**
  60881. * Configures the blur intensity used for for lens flare (halo)
  60882. */
  60883. lensFlareBlurWidth: number;
  60884. /**
  60885. * Lens star texture must be used to simulate rays on the flares and is available
  60886. * in the documentation
  60887. */
  60888. lensStarTexture: Nullable<Texture>;
  60889. /**
  60890. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60891. * flare effect by taking account of the dirt texture
  60892. */
  60893. lensFlareDirtTexture: Nullable<Texture>;
  60894. /**
  60895. * Represents the focal length for the depth of field effect
  60896. */
  60897. depthOfFieldDistance: number;
  60898. /**
  60899. * Represents the blur intensity for the blurred part of the depth of field effect
  60900. */
  60901. depthOfFieldBlurWidth: number;
  60902. /**
  60903. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60904. */
  60905. /**
  60906. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60907. */
  60908. motionStrength: number;
  60909. /**
  60910. * Gets wether or not the motion blur post-process is object based or screen based.
  60911. */
  60912. /**
  60913. * Sets wether or not the motion blur post-process should be object based or screen based
  60914. */
  60915. objectBasedMotionBlur: boolean;
  60916. /**
  60917. * List of animations for the pipeline (IAnimatable implementation)
  60918. */
  60919. animations: Animation[];
  60920. /**
  60921. * Private members
  60922. */
  60923. private _scene;
  60924. private _currentDepthOfFieldSource;
  60925. private _basePostProcess;
  60926. private _fixedExposure;
  60927. private _currentExposure;
  60928. private _hdrAutoExposure;
  60929. private _hdrCurrentLuminance;
  60930. private _motionStrength;
  60931. private _isObjectBasedMotionBlur;
  60932. private _floatTextureType;
  60933. private _camerasToBeAttached;
  60934. private _ratio;
  60935. private _bloomEnabled;
  60936. private _depthOfFieldEnabled;
  60937. private _vlsEnabled;
  60938. private _lensFlareEnabled;
  60939. private _hdrEnabled;
  60940. private _motionBlurEnabled;
  60941. private _fxaaEnabled;
  60942. private _motionBlurSamples;
  60943. private _volumetricLightStepsCount;
  60944. private _samples;
  60945. /**
  60946. * @ignore
  60947. * Specifies if the bloom pipeline is enabled
  60948. */
  60949. BloomEnabled: boolean;
  60950. /**
  60951. * @ignore
  60952. * Specifies if the depth of field pipeline is enabed
  60953. */
  60954. DepthOfFieldEnabled: boolean;
  60955. /**
  60956. * @ignore
  60957. * Specifies if the lens flare pipeline is enabed
  60958. */
  60959. LensFlareEnabled: boolean;
  60960. /**
  60961. * @ignore
  60962. * Specifies if the HDR pipeline is enabled
  60963. */
  60964. HDREnabled: boolean;
  60965. /**
  60966. * @ignore
  60967. * Specifies if the volumetric lights scattering effect is enabled
  60968. */
  60969. VLSEnabled: boolean;
  60970. /**
  60971. * @ignore
  60972. * Specifies if the motion blur effect is enabled
  60973. */
  60974. MotionBlurEnabled: boolean;
  60975. /**
  60976. * Specifies if anti-aliasing is enabled
  60977. */
  60978. fxaaEnabled: boolean;
  60979. /**
  60980. * Specifies the number of steps used to calculate the volumetric lights
  60981. * Typically in interval [50, 200]
  60982. */
  60983. volumetricLightStepsCount: number;
  60984. /**
  60985. * Specifies the number of samples used for the motion blur effect
  60986. * Typically in interval [16, 64]
  60987. */
  60988. motionBlurSamples: number;
  60989. /**
  60990. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60991. */
  60992. samples: number;
  60993. /**
  60994. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60995. * @constructor
  60996. * @param name The rendering pipeline name
  60997. * @param scene The scene linked to this pipeline
  60998. * @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)
  60999. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  61000. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61001. */
  61002. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  61003. private _buildPipeline;
  61004. private _createDownSampleX4PostProcess;
  61005. private _createBrightPassPostProcess;
  61006. private _createBlurPostProcesses;
  61007. private _createTextureAdderPostProcess;
  61008. private _createVolumetricLightPostProcess;
  61009. private _createLuminancePostProcesses;
  61010. private _createHdrPostProcess;
  61011. private _createLensFlarePostProcess;
  61012. private _createDepthOfFieldPostProcess;
  61013. private _createMotionBlurPostProcess;
  61014. private _getDepthTexture;
  61015. private _disposePostProcesses;
  61016. /**
  61017. * Dispose of the pipeline and stop all post processes
  61018. */
  61019. dispose(): void;
  61020. /**
  61021. * Serialize the rendering pipeline (Used when exporting)
  61022. * @returns the serialized object
  61023. */
  61024. serialize(): any;
  61025. /**
  61026. * Parse the serialized pipeline
  61027. * @param source Source pipeline.
  61028. * @param scene The scene to load the pipeline to.
  61029. * @param rootUrl The URL of the serialized pipeline.
  61030. * @returns An instantiated pipeline from the serialized object.
  61031. */
  61032. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  61033. /**
  61034. * Luminance steps
  61035. */
  61036. static LuminanceSteps: number;
  61037. }
  61038. }
  61039. declare module BABYLON {
  61040. /** @hidden */
  61041. export var tonemapPixelShader: {
  61042. name: string;
  61043. shader: string;
  61044. };
  61045. }
  61046. declare module BABYLON {
  61047. /** Defines operator used for tonemapping */
  61048. export enum TonemappingOperator {
  61049. /** Hable */
  61050. Hable = 0,
  61051. /** Reinhard */
  61052. Reinhard = 1,
  61053. /** HejiDawson */
  61054. HejiDawson = 2,
  61055. /** Photographic */
  61056. Photographic = 3
  61057. }
  61058. /**
  61059. * Defines a post process to apply tone mapping
  61060. */
  61061. export class TonemapPostProcess extends PostProcess {
  61062. private _operator;
  61063. /** Defines the required exposure adjustement */
  61064. exposureAdjustment: number;
  61065. /**
  61066. * Creates a new TonemapPostProcess
  61067. * @param name defines the name of the postprocess
  61068. * @param _operator defines the operator to use
  61069. * @param exposureAdjustment defines the required exposure adjustement
  61070. * @param camera defines the camera to use (can be null)
  61071. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  61072. * @param engine defines the hosting engine (can be ignore if camera is set)
  61073. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61074. */
  61075. constructor(name: string, _operator: TonemappingOperator,
  61076. /** Defines the required exposure adjustement */
  61077. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  61078. }
  61079. }
  61080. declare module BABYLON {
  61081. /** @hidden */
  61082. export var depthVertexShader: {
  61083. name: string;
  61084. shader: string;
  61085. };
  61086. }
  61087. declare module BABYLON {
  61088. /** @hidden */
  61089. export var volumetricLightScatteringPixelShader: {
  61090. name: string;
  61091. shader: string;
  61092. };
  61093. }
  61094. declare module BABYLON {
  61095. /** @hidden */
  61096. export var volumetricLightScatteringPassVertexShader: {
  61097. name: string;
  61098. shader: string;
  61099. };
  61100. }
  61101. declare module BABYLON {
  61102. /** @hidden */
  61103. export var volumetricLightScatteringPassPixelShader: {
  61104. name: string;
  61105. shader: string;
  61106. };
  61107. }
  61108. declare module BABYLON {
  61109. /**
  61110. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  61111. */
  61112. export class VolumetricLightScatteringPostProcess extends PostProcess {
  61113. private _volumetricLightScatteringPass;
  61114. private _volumetricLightScatteringRTT;
  61115. private _viewPort;
  61116. private _screenCoordinates;
  61117. private _cachedDefines;
  61118. /**
  61119. * If not undefined, the mesh position is computed from the attached node position
  61120. */
  61121. attachedNode: {
  61122. position: Vector3;
  61123. };
  61124. /**
  61125. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  61126. */
  61127. customMeshPosition: Vector3;
  61128. /**
  61129. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  61130. */
  61131. useCustomMeshPosition: boolean;
  61132. /**
  61133. * If the post-process should inverse the light scattering direction
  61134. */
  61135. invert: boolean;
  61136. /**
  61137. * The internal mesh used by the post-process
  61138. */
  61139. mesh: Mesh;
  61140. /**
  61141. * @hidden
  61142. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  61143. */
  61144. useDiffuseColor: boolean;
  61145. /**
  61146. * Array containing the excluded meshes not rendered in the internal pass
  61147. */
  61148. excludedMeshes: AbstractMesh[];
  61149. /**
  61150. * Controls the overall intensity of the post-process
  61151. */
  61152. exposure: number;
  61153. /**
  61154. * Dissipates each sample's contribution in range [0, 1]
  61155. */
  61156. decay: number;
  61157. /**
  61158. * Controls the overall intensity of each sample
  61159. */
  61160. weight: number;
  61161. /**
  61162. * Controls the density of each sample
  61163. */
  61164. density: number;
  61165. /**
  61166. * @constructor
  61167. * @param name The post-process name
  61168. * @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)
  61169. * @param camera The camera that the post-process will be attached to
  61170. * @param mesh The mesh used to create the light scattering
  61171. * @param samples The post-process quality, default 100
  61172. * @param samplingModeThe post-process filtering mode
  61173. * @param engine The babylon engine
  61174. * @param reusable If the post-process is reusable
  61175. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  61176. */
  61177. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  61178. /**
  61179. * Returns the string "VolumetricLightScatteringPostProcess"
  61180. * @returns "VolumetricLightScatteringPostProcess"
  61181. */
  61182. getClassName(): string;
  61183. private _isReady;
  61184. /**
  61185. * Sets the new light position for light scattering effect
  61186. * @param position The new custom light position
  61187. */
  61188. setCustomMeshPosition(position: Vector3): void;
  61189. /**
  61190. * Returns the light position for light scattering effect
  61191. * @return Vector3 The custom light position
  61192. */
  61193. getCustomMeshPosition(): Vector3;
  61194. /**
  61195. * Disposes the internal assets and detaches the post-process from the camera
  61196. */
  61197. dispose(camera: Camera): void;
  61198. /**
  61199. * Returns the render target texture used by the post-process
  61200. * @return the render target texture used by the post-process
  61201. */
  61202. getPass(): RenderTargetTexture;
  61203. private _meshExcluded;
  61204. private _createPass;
  61205. private _updateMeshScreenCoordinates;
  61206. /**
  61207. * Creates a default mesh for the Volumeric Light Scattering post-process
  61208. * @param name The mesh name
  61209. * @param scene The scene where to create the mesh
  61210. * @return the default mesh
  61211. */
  61212. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  61213. }
  61214. }
  61215. declare module BABYLON {
  61216. interface Scene {
  61217. /** @hidden (Backing field) */
  61218. _boundingBoxRenderer: BoundingBoxRenderer;
  61219. /** @hidden (Backing field) */
  61220. _forceShowBoundingBoxes: boolean;
  61221. /**
  61222. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  61223. */
  61224. forceShowBoundingBoxes: boolean;
  61225. /**
  61226. * Gets the bounding box renderer associated with the scene
  61227. * @returns a BoundingBoxRenderer
  61228. */
  61229. getBoundingBoxRenderer(): BoundingBoxRenderer;
  61230. }
  61231. interface AbstractMesh {
  61232. /** @hidden (Backing field) */
  61233. _showBoundingBox: boolean;
  61234. /**
  61235. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  61236. */
  61237. showBoundingBox: boolean;
  61238. }
  61239. /**
  61240. * Component responsible of rendering the bounding box of the meshes in a scene.
  61241. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  61242. */
  61243. export class BoundingBoxRenderer implements ISceneComponent {
  61244. /**
  61245. * The component name helpfull to identify the component in the list of scene components.
  61246. */
  61247. readonly name: string;
  61248. /**
  61249. * The scene the component belongs to.
  61250. */
  61251. scene: Scene;
  61252. /**
  61253. * Color of the bounding box lines placed in front of an object
  61254. */
  61255. frontColor: Color3;
  61256. /**
  61257. * Color of the bounding box lines placed behind an object
  61258. */
  61259. backColor: Color3;
  61260. /**
  61261. * Defines if the renderer should show the back lines or not
  61262. */
  61263. showBackLines: boolean;
  61264. /**
  61265. * @hidden
  61266. */
  61267. renderList: SmartArray<BoundingBox>;
  61268. private _colorShader;
  61269. private _vertexBuffers;
  61270. private _indexBuffer;
  61271. private _fillIndexBuffer;
  61272. private _fillIndexData;
  61273. /**
  61274. * Instantiates a new bounding box renderer in a scene.
  61275. * @param scene the scene the renderer renders in
  61276. */
  61277. constructor(scene: Scene);
  61278. /**
  61279. * Registers the component in a given scene
  61280. */
  61281. register(): void;
  61282. private _evaluateSubMesh;
  61283. private _activeMesh;
  61284. private _prepareRessources;
  61285. private _createIndexBuffer;
  61286. /**
  61287. * Rebuilds the elements related to this component in case of
  61288. * context lost for instance.
  61289. */
  61290. rebuild(): void;
  61291. /**
  61292. * @hidden
  61293. */
  61294. reset(): void;
  61295. /**
  61296. * Render the bounding boxes of a specific rendering group
  61297. * @param renderingGroupId defines the rendering group to render
  61298. */
  61299. render(renderingGroupId: number): void;
  61300. /**
  61301. * In case of occlusion queries, we can render the occlusion bounding box through this method
  61302. * @param mesh Define the mesh to render the occlusion bounding box for
  61303. */
  61304. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  61305. /**
  61306. * Dispose and release the resources attached to this renderer.
  61307. */
  61308. dispose(): void;
  61309. }
  61310. }
  61311. declare module BABYLON {
  61312. /** @hidden */
  61313. export var depthPixelShader: {
  61314. name: string;
  61315. shader: string;
  61316. };
  61317. }
  61318. declare module BABYLON {
  61319. /**
  61320. * This represents a depth renderer in Babylon.
  61321. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61322. */
  61323. export class DepthRenderer {
  61324. private _scene;
  61325. private _depthMap;
  61326. private _effect;
  61327. private readonly _storeNonLinearDepth;
  61328. private readonly _clearColor;
  61329. /** Get if the depth renderer is using packed depth or not */
  61330. readonly isPacked: boolean;
  61331. private _cachedDefines;
  61332. private _camera;
  61333. /**
  61334. * Specifiess that the depth renderer will only be used within
  61335. * the camera it is created for.
  61336. * This can help forcing its rendering during the camera processing.
  61337. */
  61338. useOnlyInActiveCamera: boolean;
  61339. /** @hidden */
  61340. static _SceneComponentInitialization: (scene: Scene) => void;
  61341. /**
  61342. * Instantiates a depth renderer
  61343. * @param scene The scene the renderer belongs to
  61344. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61345. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61346. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61347. */
  61348. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61349. /**
  61350. * Creates the depth rendering effect and checks if the effect is ready.
  61351. * @param subMesh The submesh to be used to render the depth map of
  61352. * @param useInstances If multiple world instances should be used
  61353. * @returns if the depth renderer is ready to render the depth map
  61354. */
  61355. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61356. /**
  61357. * Gets the texture which the depth map will be written to.
  61358. * @returns The depth map texture
  61359. */
  61360. getDepthMap(): RenderTargetTexture;
  61361. /**
  61362. * Disposes of the depth renderer.
  61363. */
  61364. dispose(): void;
  61365. }
  61366. }
  61367. declare module BABYLON {
  61368. interface Scene {
  61369. /** @hidden (Backing field) */
  61370. _depthRenderer: {
  61371. [id: string]: DepthRenderer;
  61372. };
  61373. /**
  61374. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  61375. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  61376. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61377. * @returns the created depth renderer
  61378. */
  61379. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  61380. /**
  61381. * Disables a depth renderer for a given camera
  61382. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  61383. */
  61384. disableDepthRenderer(camera?: Nullable<Camera>): void;
  61385. }
  61386. /**
  61387. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  61388. * in several rendering techniques.
  61389. */
  61390. export class DepthRendererSceneComponent implements ISceneComponent {
  61391. /**
  61392. * The component name helpfull to identify the component in the list of scene components.
  61393. */
  61394. readonly name: string;
  61395. /**
  61396. * The scene the component belongs to.
  61397. */
  61398. scene: Scene;
  61399. /**
  61400. * Creates a new instance of the component for the given scene
  61401. * @param scene Defines the scene to register the component in
  61402. */
  61403. constructor(scene: Scene);
  61404. /**
  61405. * Registers the component in a given scene
  61406. */
  61407. register(): void;
  61408. /**
  61409. * Rebuilds the elements related to this component in case of
  61410. * context lost for instance.
  61411. */
  61412. rebuild(): void;
  61413. /**
  61414. * Disposes the component and the associated ressources
  61415. */
  61416. dispose(): void;
  61417. private _gatherRenderTargets;
  61418. private _gatherActiveCameraRenderTargets;
  61419. }
  61420. }
  61421. declare module BABYLON {
  61422. /** @hidden */
  61423. export var outlinePixelShader: {
  61424. name: string;
  61425. shader: string;
  61426. };
  61427. }
  61428. declare module BABYLON {
  61429. /** @hidden */
  61430. export var outlineVertexShader: {
  61431. name: string;
  61432. shader: string;
  61433. };
  61434. }
  61435. declare module BABYLON {
  61436. interface Scene {
  61437. /** @hidden */
  61438. _outlineRenderer: OutlineRenderer;
  61439. /**
  61440. * Gets the outline renderer associated with the scene
  61441. * @returns a OutlineRenderer
  61442. */
  61443. getOutlineRenderer(): OutlineRenderer;
  61444. }
  61445. interface AbstractMesh {
  61446. /** @hidden (Backing field) */
  61447. _renderOutline: boolean;
  61448. /**
  61449. * Gets or sets a boolean indicating if the outline must be rendered as well
  61450. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  61451. */
  61452. renderOutline: boolean;
  61453. /** @hidden (Backing field) */
  61454. _renderOverlay: boolean;
  61455. /**
  61456. * Gets or sets a boolean indicating if the overlay must be rendered as well
  61457. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  61458. */
  61459. renderOverlay: boolean;
  61460. }
  61461. /**
  61462. * This class is responsible to draw bothe outline/overlay of meshes.
  61463. * It should not be used directly but through the available method on mesh.
  61464. */
  61465. export class OutlineRenderer implements ISceneComponent {
  61466. /**
  61467. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  61468. */
  61469. private static _StencilReference;
  61470. /**
  61471. * The name of the component. Each component must have a unique name.
  61472. */
  61473. name: string;
  61474. /**
  61475. * The scene the component belongs to.
  61476. */
  61477. scene: Scene;
  61478. /**
  61479. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  61480. */
  61481. zOffset: number;
  61482. private _engine;
  61483. private _effect;
  61484. private _cachedDefines;
  61485. private _savedDepthWrite;
  61486. /**
  61487. * Instantiates a new outline renderer. (There could be only one per scene).
  61488. * @param scene Defines the scene it belongs to
  61489. */
  61490. constructor(scene: Scene);
  61491. /**
  61492. * Register the component to one instance of a scene.
  61493. */
  61494. register(): void;
  61495. /**
  61496. * Rebuilds the elements related to this component in case of
  61497. * context lost for instance.
  61498. */
  61499. rebuild(): void;
  61500. /**
  61501. * Disposes the component and the associated ressources.
  61502. */
  61503. dispose(): void;
  61504. /**
  61505. * Renders the outline in the canvas.
  61506. * @param subMesh Defines the sumesh to render
  61507. * @param batch Defines the batch of meshes in case of instances
  61508. * @param useOverlay Defines if the rendering is for the overlay or the outline
  61509. */
  61510. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  61511. /**
  61512. * Returns whether or not the outline renderer is ready for a given submesh.
  61513. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  61514. * @param subMesh Defines the submesh to check readyness for
  61515. * @param useInstances Defines wheter wee are trying to render instances or not
  61516. * @returns true if ready otherwise false
  61517. */
  61518. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61519. private _beforeRenderingMesh;
  61520. private _afterRenderingMesh;
  61521. }
  61522. }
  61523. declare module BABYLON {
  61524. /**
  61525. * Class used to manage multiple sprites of different sizes on the same spritesheet
  61526. * @see http://doc.babylonjs.com/babylon101/sprites
  61527. */
  61528. export class SpritePackedManager extends SpriteManager {
  61529. /** defines the packed manager's name */
  61530. name: string;
  61531. /**
  61532. * Creates a new sprite manager from a packed sprite sheet
  61533. * @param name defines the manager's name
  61534. * @param imgUrl defines the sprite sheet url
  61535. * @param capacity defines the maximum allowed number of sprites
  61536. * @param scene defines the hosting scene
  61537. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  61538. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  61539. * @param samplingMode defines the smapling mode to use with spritesheet
  61540. * @param fromPacked set to true; do not alter
  61541. */
  61542. constructor(
  61543. /** defines the packed manager's name */
  61544. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  61545. }
  61546. }
  61547. declare module BABYLON {
  61548. /**
  61549. * Defines the list of states available for a task inside a AssetsManager
  61550. */
  61551. export enum AssetTaskState {
  61552. /**
  61553. * Initialization
  61554. */
  61555. INIT = 0,
  61556. /**
  61557. * Running
  61558. */
  61559. RUNNING = 1,
  61560. /**
  61561. * Done
  61562. */
  61563. DONE = 2,
  61564. /**
  61565. * Error
  61566. */
  61567. ERROR = 3
  61568. }
  61569. /**
  61570. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  61571. */
  61572. export abstract class AbstractAssetTask {
  61573. /**
  61574. * Task name
  61575. */ name: string;
  61576. /**
  61577. * Callback called when the task is successful
  61578. */
  61579. onSuccess: (task: any) => void;
  61580. /**
  61581. * Callback called when the task is not successful
  61582. */
  61583. onError: (task: any, message?: string, exception?: any) => void;
  61584. /**
  61585. * Creates a new AssetsManager
  61586. * @param name defines the name of the task
  61587. */
  61588. constructor(
  61589. /**
  61590. * Task name
  61591. */ name: string);
  61592. private _isCompleted;
  61593. private _taskState;
  61594. private _errorObject;
  61595. /**
  61596. * Get if the task is completed
  61597. */
  61598. readonly isCompleted: boolean;
  61599. /**
  61600. * Gets the current state of the task
  61601. */
  61602. readonly taskState: AssetTaskState;
  61603. /**
  61604. * Gets the current error object (if task is in error)
  61605. */
  61606. readonly errorObject: {
  61607. message?: string;
  61608. exception?: any;
  61609. };
  61610. /**
  61611. * Internal only
  61612. * @hidden
  61613. */
  61614. _setErrorObject(message?: string, exception?: any): void;
  61615. /**
  61616. * Execute the current task
  61617. * @param scene defines the scene where you want your assets to be loaded
  61618. * @param onSuccess is a callback called when the task is successfully executed
  61619. * @param onError is a callback called if an error occurs
  61620. */
  61621. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61622. /**
  61623. * Execute the current task
  61624. * @param scene defines the scene where you want your assets to be loaded
  61625. * @param onSuccess is a callback called when the task is successfully executed
  61626. * @param onError is a callback called if an error occurs
  61627. */
  61628. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61629. /**
  61630. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  61631. * This can be used with failed tasks that have the reason for failure fixed.
  61632. */
  61633. reset(): void;
  61634. private onErrorCallback;
  61635. private onDoneCallback;
  61636. }
  61637. /**
  61638. * Define the interface used by progress events raised during assets loading
  61639. */
  61640. export interface IAssetsProgressEvent {
  61641. /**
  61642. * Defines the number of remaining tasks to process
  61643. */
  61644. remainingCount: number;
  61645. /**
  61646. * Defines the total number of tasks
  61647. */
  61648. totalCount: number;
  61649. /**
  61650. * Defines the task that was just processed
  61651. */
  61652. task: AbstractAssetTask;
  61653. }
  61654. /**
  61655. * Class used to share progress information about assets loading
  61656. */
  61657. export class AssetsProgressEvent implements IAssetsProgressEvent {
  61658. /**
  61659. * Defines the number of remaining tasks to process
  61660. */
  61661. remainingCount: number;
  61662. /**
  61663. * Defines the total number of tasks
  61664. */
  61665. totalCount: number;
  61666. /**
  61667. * Defines the task that was just processed
  61668. */
  61669. task: AbstractAssetTask;
  61670. /**
  61671. * Creates a AssetsProgressEvent
  61672. * @param remainingCount defines the number of remaining tasks to process
  61673. * @param totalCount defines the total number of tasks
  61674. * @param task defines the task that was just processed
  61675. */
  61676. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  61677. }
  61678. /**
  61679. * Define a task used by AssetsManager to load meshes
  61680. */
  61681. export class MeshAssetTask extends AbstractAssetTask {
  61682. /**
  61683. * Defines the name of the task
  61684. */
  61685. name: string;
  61686. /**
  61687. * Defines the list of mesh's names you want to load
  61688. */
  61689. meshesNames: any;
  61690. /**
  61691. * Defines the root url to use as a base to load your meshes and associated resources
  61692. */
  61693. rootUrl: string;
  61694. /**
  61695. * Defines the filename of the scene to load from
  61696. */
  61697. sceneFilename: string;
  61698. /**
  61699. * Gets the list of loaded meshes
  61700. */
  61701. loadedMeshes: Array<AbstractMesh>;
  61702. /**
  61703. * Gets the list of loaded particle systems
  61704. */
  61705. loadedParticleSystems: Array<IParticleSystem>;
  61706. /**
  61707. * Gets the list of loaded skeletons
  61708. */
  61709. loadedSkeletons: Array<Skeleton>;
  61710. /**
  61711. * Gets the list of loaded animation groups
  61712. */
  61713. loadedAnimationGroups: Array<AnimationGroup>;
  61714. /**
  61715. * Callback called when the task is successful
  61716. */
  61717. onSuccess: (task: MeshAssetTask) => void;
  61718. /**
  61719. * Callback called when the task is successful
  61720. */
  61721. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  61722. /**
  61723. * Creates a new MeshAssetTask
  61724. * @param name defines the name of the task
  61725. * @param meshesNames defines the list of mesh's names you want to load
  61726. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  61727. * @param sceneFilename defines the filename of the scene to load from
  61728. */
  61729. constructor(
  61730. /**
  61731. * Defines the name of the task
  61732. */
  61733. name: string,
  61734. /**
  61735. * Defines the list of mesh's names you want to load
  61736. */
  61737. meshesNames: any,
  61738. /**
  61739. * Defines the root url to use as a base to load your meshes and associated resources
  61740. */
  61741. rootUrl: string,
  61742. /**
  61743. * Defines the filename of the scene to load from
  61744. */
  61745. sceneFilename: string);
  61746. /**
  61747. * Execute the current task
  61748. * @param scene defines the scene where you want your assets to be loaded
  61749. * @param onSuccess is a callback called when the task is successfully executed
  61750. * @param onError is a callback called if an error occurs
  61751. */
  61752. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61753. }
  61754. /**
  61755. * Define a task used by AssetsManager to load text content
  61756. */
  61757. export class TextFileAssetTask extends AbstractAssetTask {
  61758. /**
  61759. * Defines the name of the task
  61760. */
  61761. name: string;
  61762. /**
  61763. * Defines the location of the file to load
  61764. */
  61765. url: string;
  61766. /**
  61767. * Gets the loaded text string
  61768. */
  61769. text: string;
  61770. /**
  61771. * Callback called when the task is successful
  61772. */
  61773. onSuccess: (task: TextFileAssetTask) => void;
  61774. /**
  61775. * Callback called when the task is successful
  61776. */
  61777. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  61778. /**
  61779. * Creates a new TextFileAssetTask object
  61780. * @param name defines the name of the task
  61781. * @param url defines the location of the file to load
  61782. */
  61783. constructor(
  61784. /**
  61785. * Defines the name of the task
  61786. */
  61787. name: string,
  61788. /**
  61789. * Defines the location of the file to load
  61790. */
  61791. url: string);
  61792. /**
  61793. * Execute the current task
  61794. * @param scene defines the scene where you want your assets to be loaded
  61795. * @param onSuccess is a callback called when the task is successfully executed
  61796. * @param onError is a callback called if an error occurs
  61797. */
  61798. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61799. }
  61800. /**
  61801. * Define a task used by AssetsManager to load binary data
  61802. */
  61803. export class BinaryFileAssetTask extends AbstractAssetTask {
  61804. /**
  61805. * Defines the name of the task
  61806. */
  61807. name: string;
  61808. /**
  61809. * Defines the location of the file to load
  61810. */
  61811. url: string;
  61812. /**
  61813. * Gets the lodaded data (as an array buffer)
  61814. */
  61815. data: ArrayBuffer;
  61816. /**
  61817. * Callback called when the task is successful
  61818. */
  61819. onSuccess: (task: BinaryFileAssetTask) => void;
  61820. /**
  61821. * Callback called when the task is successful
  61822. */
  61823. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61824. /**
  61825. * Creates a new BinaryFileAssetTask object
  61826. * @param name defines the name of the new task
  61827. * @param url defines the location of the file to load
  61828. */
  61829. constructor(
  61830. /**
  61831. * Defines the name of the task
  61832. */
  61833. name: string,
  61834. /**
  61835. * Defines the location of the file to load
  61836. */
  61837. url: string);
  61838. /**
  61839. * Execute the current task
  61840. * @param scene defines the scene where you want your assets to be loaded
  61841. * @param onSuccess is a callback called when the task is successfully executed
  61842. * @param onError is a callback called if an error occurs
  61843. */
  61844. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61845. }
  61846. /**
  61847. * Define a task used by AssetsManager to load images
  61848. */
  61849. export class ImageAssetTask extends AbstractAssetTask {
  61850. /**
  61851. * Defines the name of the task
  61852. */
  61853. name: string;
  61854. /**
  61855. * Defines the location of the image to load
  61856. */
  61857. url: string;
  61858. /**
  61859. * Gets the loaded images
  61860. */
  61861. image: HTMLImageElement;
  61862. /**
  61863. * Callback called when the task is successful
  61864. */
  61865. onSuccess: (task: ImageAssetTask) => void;
  61866. /**
  61867. * Callback called when the task is successful
  61868. */
  61869. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61870. /**
  61871. * Creates a new ImageAssetTask
  61872. * @param name defines the name of the task
  61873. * @param url defines the location of the image to load
  61874. */
  61875. constructor(
  61876. /**
  61877. * Defines the name of the task
  61878. */
  61879. name: string,
  61880. /**
  61881. * Defines the location of the image to load
  61882. */
  61883. url: string);
  61884. /**
  61885. * Execute the current task
  61886. * @param scene defines the scene where you want your assets to be loaded
  61887. * @param onSuccess is a callback called when the task is successfully executed
  61888. * @param onError is a callback called if an error occurs
  61889. */
  61890. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61891. }
  61892. /**
  61893. * Defines the interface used by texture loading tasks
  61894. */
  61895. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61896. /**
  61897. * Gets the loaded texture
  61898. */
  61899. texture: TEX;
  61900. }
  61901. /**
  61902. * Define a task used by AssetsManager to load 2D textures
  61903. */
  61904. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61905. /**
  61906. * Defines the name of the task
  61907. */
  61908. name: string;
  61909. /**
  61910. * Defines the location of the file to load
  61911. */
  61912. url: string;
  61913. /**
  61914. * Defines if mipmap should not be generated (default is false)
  61915. */
  61916. noMipmap?: boolean | undefined;
  61917. /**
  61918. * Defines if texture must be inverted on Y axis (default is false)
  61919. */
  61920. invertY?: boolean | undefined;
  61921. /**
  61922. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61923. */
  61924. samplingMode: number;
  61925. /**
  61926. * Gets the loaded texture
  61927. */
  61928. texture: Texture;
  61929. /**
  61930. * Callback called when the task is successful
  61931. */
  61932. onSuccess: (task: TextureAssetTask) => void;
  61933. /**
  61934. * Callback called when the task is successful
  61935. */
  61936. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61937. /**
  61938. * Creates a new TextureAssetTask object
  61939. * @param name defines the name of the task
  61940. * @param url defines the location of the file to load
  61941. * @param noMipmap defines if mipmap should not be generated (default is false)
  61942. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61943. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61944. */
  61945. constructor(
  61946. /**
  61947. * Defines the name of the task
  61948. */
  61949. name: string,
  61950. /**
  61951. * Defines the location of the file to load
  61952. */
  61953. url: string,
  61954. /**
  61955. * Defines if mipmap should not be generated (default is false)
  61956. */
  61957. noMipmap?: boolean | undefined,
  61958. /**
  61959. * Defines if texture must be inverted on Y axis (default is false)
  61960. */
  61961. invertY?: boolean | undefined,
  61962. /**
  61963. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61964. */
  61965. samplingMode?: number);
  61966. /**
  61967. * Execute the current task
  61968. * @param scene defines the scene where you want your assets to be loaded
  61969. * @param onSuccess is a callback called when the task is successfully executed
  61970. * @param onError is a callback called if an error occurs
  61971. */
  61972. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61973. }
  61974. /**
  61975. * Define a task used by AssetsManager to load cube textures
  61976. */
  61977. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61978. /**
  61979. * Defines the name of the task
  61980. */
  61981. name: string;
  61982. /**
  61983. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61984. */
  61985. url: string;
  61986. /**
  61987. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61988. */
  61989. extensions?: string[] | undefined;
  61990. /**
  61991. * Defines if mipmaps should not be generated (default is false)
  61992. */
  61993. noMipmap?: boolean | undefined;
  61994. /**
  61995. * Defines the explicit list of files (undefined by default)
  61996. */
  61997. files?: string[] | undefined;
  61998. /**
  61999. * Gets the loaded texture
  62000. */
  62001. texture: CubeTexture;
  62002. /**
  62003. * Callback called when the task is successful
  62004. */
  62005. onSuccess: (task: CubeTextureAssetTask) => void;
  62006. /**
  62007. * Callback called when the task is successful
  62008. */
  62009. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  62010. /**
  62011. * Creates a new CubeTextureAssetTask
  62012. * @param name defines the name of the task
  62013. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62014. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62015. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62016. * @param files defines the explicit list of files (undefined by default)
  62017. */
  62018. constructor(
  62019. /**
  62020. * Defines the name of the task
  62021. */
  62022. name: string,
  62023. /**
  62024. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62025. */
  62026. url: string,
  62027. /**
  62028. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62029. */
  62030. extensions?: string[] | undefined,
  62031. /**
  62032. * Defines if mipmaps should not be generated (default is false)
  62033. */
  62034. noMipmap?: boolean | undefined,
  62035. /**
  62036. * Defines the explicit list of files (undefined by default)
  62037. */
  62038. files?: string[] | undefined);
  62039. /**
  62040. * Execute the current task
  62041. * @param scene defines the scene where you want your assets to be loaded
  62042. * @param onSuccess is a callback called when the task is successfully executed
  62043. * @param onError is a callback called if an error occurs
  62044. */
  62045. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62046. }
  62047. /**
  62048. * Define a task used by AssetsManager to load HDR cube textures
  62049. */
  62050. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  62051. /**
  62052. * Defines the name of the task
  62053. */
  62054. name: string;
  62055. /**
  62056. * Defines the location of the file to load
  62057. */
  62058. url: string;
  62059. /**
  62060. * Defines the desired size (the more it increases the longer the generation will be)
  62061. */
  62062. size: number;
  62063. /**
  62064. * Defines if mipmaps should not be generated (default is false)
  62065. */
  62066. noMipmap: boolean;
  62067. /**
  62068. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62069. */
  62070. generateHarmonics: boolean;
  62071. /**
  62072. * 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)
  62073. */
  62074. gammaSpace: boolean;
  62075. /**
  62076. * Internal Use Only
  62077. */
  62078. reserved: boolean;
  62079. /**
  62080. * Gets the loaded texture
  62081. */
  62082. texture: HDRCubeTexture;
  62083. /**
  62084. * Callback called when the task is successful
  62085. */
  62086. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  62087. /**
  62088. * Callback called when the task is successful
  62089. */
  62090. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  62091. /**
  62092. * Creates a new HDRCubeTextureAssetTask object
  62093. * @param name defines the name of the task
  62094. * @param url defines the location of the file to load
  62095. * @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.
  62096. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62097. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62098. * @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)
  62099. * @param reserved Internal use only
  62100. */
  62101. constructor(
  62102. /**
  62103. * Defines the name of the task
  62104. */
  62105. name: string,
  62106. /**
  62107. * Defines the location of the file to load
  62108. */
  62109. url: string,
  62110. /**
  62111. * Defines the desired size (the more it increases the longer the generation will be)
  62112. */
  62113. size: number,
  62114. /**
  62115. * Defines if mipmaps should not be generated (default is false)
  62116. */
  62117. noMipmap?: boolean,
  62118. /**
  62119. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62120. */
  62121. generateHarmonics?: boolean,
  62122. /**
  62123. * 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)
  62124. */
  62125. gammaSpace?: boolean,
  62126. /**
  62127. * Internal Use Only
  62128. */
  62129. reserved?: boolean);
  62130. /**
  62131. * Execute the current task
  62132. * @param scene defines the scene where you want your assets to be loaded
  62133. * @param onSuccess is a callback called when the task is successfully executed
  62134. * @param onError is a callback called if an error occurs
  62135. */
  62136. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62137. }
  62138. /**
  62139. * Define a task used by AssetsManager to load Equirectangular cube textures
  62140. */
  62141. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  62142. /**
  62143. * Defines the name of the task
  62144. */
  62145. name: string;
  62146. /**
  62147. * Defines the location of the file to load
  62148. */
  62149. url: string;
  62150. /**
  62151. * Defines the desired size (the more it increases the longer the generation will be)
  62152. */
  62153. size: number;
  62154. /**
  62155. * Defines if mipmaps should not be generated (default is false)
  62156. */
  62157. noMipmap: boolean;
  62158. /**
  62159. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62160. * but the standard material would require them in Gamma space) (default is true)
  62161. */
  62162. gammaSpace: boolean;
  62163. /**
  62164. * Gets the loaded texture
  62165. */
  62166. texture: EquiRectangularCubeTexture;
  62167. /**
  62168. * Callback called when the task is successful
  62169. */
  62170. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  62171. /**
  62172. * Callback called when the task is successful
  62173. */
  62174. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  62175. /**
  62176. * Creates a new EquiRectangularCubeTextureAssetTask object
  62177. * @param name defines the name of the task
  62178. * @param url defines the location of the file to load
  62179. * @param size defines the desired size (the more it increases the longer the generation will be)
  62180. * If the size is omitted this implies you are using a preprocessed cubemap.
  62181. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62182. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  62183. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  62184. * (default is true)
  62185. */
  62186. constructor(
  62187. /**
  62188. * Defines the name of the task
  62189. */
  62190. name: string,
  62191. /**
  62192. * Defines the location of the file to load
  62193. */
  62194. url: string,
  62195. /**
  62196. * Defines the desired size (the more it increases the longer the generation will be)
  62197. */
  62198. size: number,
  62199. /**
  62200. * Defines if mipmaps should not be generated (default is false)
  62201. */
  62202. noMipmap?: boolean,
  62203. /**
  62204. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62205. * but the standard material would require them in Gamma space) (default is true)
  62206. */
  62207. gammaSpace?: boolean);
  62208. /**
  62209. * Execute the current task
  62210. * @param scene defines the scene where you want your assets to be loaded
  62211. * @param onSuccess is a callback called when the task is successfully executed
  62212. * @param onError is a callback called if an error occurs
  62213. */
  62214. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62215. }
  62216. /**
  62217. * This class can be used to easily import assets into a scene
  62218. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  62219. */
  62220. export class AssetsManager {
  62221. private _scene;
  62222. private _isLoading;
  62223. protected _tasks: AbstractAssetTask[];
  62224. protected _waitingTasksCount: number;
  62225. protected _totalTasksCount: number;
  62226. /**
  62227. * Callback called when all tasks are processed
  62228. */
  62229. onFinish: (tasks: AbstractAssetTask[]) => void;
  62230. /**
  62231. * Callback called when a task is successful
  62232. */
  62233. onTaskSuccess: (task: AbstractAssetTask) => void;
  62234. /**
  62235. * Callback called when a task had an error
  62236. */
  62237. onTaskError: (task: AbstractAssetTask) => void;
  62238. /**
  62239. * Callback called when a task is done (whatever the result is)
  62240. */
  62241. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  62242. /**
  62243. * Observable called when all tasks are processed
  62244. */
  62245. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  62246. /**
  62247. * Observable called when a task had an error
  62248. */
  62249. onTaskErrorObservable: Observable<AbstractAssetTask>;
  62250. /**
  62251. * Observable called when all tasks were executed
  62252. */
  62253. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  62254. /**
  62255. * Observable called when a task is done (whatever the result is)
  62256. */
  62257. onProgressObservable: Observable<IAssetsProgressEvent>;
  62258. /**
  62259. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  62260. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  62261. */
  62262. useDefaultLoadingScreen: boolean;
  62263. /**
  62264. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  62265. * when all assets have been downloaded.
  62266. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  62267. */
  62268. autoHideLoadingUI: boolean;
  62269. /**
  62270. * Creates a new AssetsManager
  62271. * @param scene defines the scene to work on
  62272. */
  62273. constructor(scene: Scene);
  62274. /**
  62275. * Add a MeshAssetTask to the list of active tasks
  62276. * @param taskName defines the name of the new task
  62277. * @param meshesNames defines the name of meshes to load
  62278. * @param rootUrl defines the root url to use to locate files
  62279. * @param sceneFilename defines the filename of the scene file
  62280. * @returns a new MeshAssetTask object
  62281. */
  62282. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  62283. /**
  62284. * Add a TextFileAssetTask to the list of active tasks
  62285. * @param taskName defines the name of the new task
  62286. * @param url defines the url of the file to load
  62287. * @returns a new TextFileAssetTask object
  62288. */
  62289. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  62290. /**
  62291. * Add a BinaryFileAssetTask to the list of active tasks
  62292. * @param taskName defines the name of the new task
  62293. * @param url defines the url of the file to load
  62294. * @returns a new BinaryFileAssetTask object
  62295. */
  62296. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  62297. /**
  62298. * Add a ImageAssetTask to the list of active tasks
  62299. * @param taskName defines the name of the new task
  62300. * @param url defines the url of the file to load
  62301. * @returns a new ImageAssetTask object
  62302. */
  62303. addImageTask(taskName: string, url: string): ImageAssetTask;
  62304. /**
  62305. * Add a TextureAssetTask to the list of active tasks
  62306. * @param taskName defines the name of the new task
  62307. * @param url defines the url of the file to load
  62308. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62309. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  62310. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62311. * @returns a new TextureAssetTask object
  62312. */
  62313. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  62314. /**
  62315. * Add a CubeTextureAssetTask to the list of active tasks
  62316. * @param taskName defines the name of the new task
  62317. * @param url defines the url of the file to load
  62318. * @param extensions defines the extension to use to load the cube map (can be null)
  62319. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62320. * @param files defines the list of files to load (can be null)
  62321. * @returns a new CubeTextureAssetTask object
  62322. */
  62323. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  62324. /**
  62325. *
  62326. * Add a HDRCubeTextureAssetTask to the list of active tasks
  62327. * @param taskName defines the name of the new task
  62328. * @param url defines the url of the file to load
  62329. * @param size defines the size you want for the cubemap (can be null)
  62330. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62331. * @param generateHarmonics defines if you want to automatically generate (true by default)
  62332. * @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)
  62333. * @param reserved Internal use only
  62334. * @returns a new HDRCubeTextureAssetTask object
  62335. */
  62336. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  62337. /**
  62338. *
  62339. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  62340. * @param taskName defines the name of the new task
  62341. * @param url defines the url of the file to load
  62342. * @param size defines the size you want for the cubemap (can be null)
  62343. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62344. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62345. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62346. * @returns a new EquiRectangularCubeTextureAssetTask object
  62347. */
  62348. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  62349. /**
  62350. * Remove a task from the assets manager.
  62351. * @param task the task to remove
  62352. */
  62353. removeTask(task: AbstractAssetTask): void;
  62354. private _decreaseWaitingTasksCount;
  62355. private _runTask;
  62356. /**
  62357. * Reset the AssetsManager and remove all tasks
  62358. * @return the current instance of the AssetsManager
  62359. */
  62360. reset(): AssetsManager;
  62361. /**
  62362. * Start the loading process
  62363. * @return the current instance of the AssetsManager
  62364. */
  62365. load(): AssetsManager;
  62366. /**
  62367. * Start the loading process as an async operation
  62368. * @return a promise returning the list of failed tasks
  62369. */
  62370. loadAsync(): Promise<void>;
  62371. }
  62372. }
  62373. declare module BABYLON {
  62374. /**
  62375. * Wrapper class for promise with external resolve and reject.
  62376. */
  62377. export class Deferred<T> {
  62378. /**
  62379. * The promise associated with this deferred object.
  62380. */
  62381. readonly promise: Promise<T>;
  62382. private _resolve;
  62383. private _reject;
  62384. /**
  62385. * The resolve method of the promise associated with this deferred object.
  62386. */
  62387. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  62388. /**
  62389. * The reject method of the promise associated with this deferred object.
  62390. */
  62391. readonly reject: (reason?: any) => void;
  62392. /**
  62393. * Constructor for this deferred object.
  62394. */
  62395. constructor();
  62396. }
  62397. }
  62398. declare module BABYLON {
  62399. /**
  62400. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  62401. */
  62402. export class MeshExploder {
  62403. private _centerMesh;
  62404. private _meshes;
  62405. private _meshesOrigins;
  62406. private _toCenterVectors;
  62407. private _scaledDirection;
  62408. private _newPosition;
  62409. private _centerPosition;
  62410. /**
  62411. * Explodes meshes from a center mesh.
  62412. * @param meshes The meshes to explode.
  62413. * @param centerMesh The mesh to be center of explosion.
  62414. */
  62415. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  62416. private _setCenterMesh;
  62417. /**
  62418. * Get class name
  62419. * @returns "MeshExploder"
  62420. */
  62421. getClassName(): string;
  62422. /**
  62423. * "Exploded meshes"
  62424. * @returns Array of meshes with the centerMesh at index 0.
  62425. */
  62426. getMeshes(): Array<Mesh>;
  62427. /**
  62428. * Explodes meshes giving a specific direction
  62429. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  62430. */
  62431. explode(direction?: number): void;
  62432. }
  62433. }
  62434. declare module BABYLON {
  62435. /**
  62436. * Class used to help managing file picking and drag'n'drop
  62437. */
  62438. export class FilesInput {
  62439. /**
  62440. * List of files ready to be loaded
  62441. */
  62442. static readonly FilesToLoad: {
  62443. [key: string]: File;
  62444. };
  62445. /**
  62446. * Callback called when a file is processed
  62447. */
  62448. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  62449. private _engine;
  62450. private _currentScene;
  62451. private _sceneLoadedCallback;
  62452. private _progressCallback;
  62453. private _additionalRenderLoopLogicCallback;
  62454. private _textureLoadingCallback;
  62455. private _startingProcessingFilesCallback;
  62456. private _onReloadCallback;
  62457. private _errorCallback;
  62458. private _elementToMonitor;
  62459. private _sceneFileToLoad;
  62460. private _filesToLoad;
  62461. /**
  62462. * Creates a new FilesInput
  62463. * @param engine defines the rendering engine
  62464. * @param scene defines the hosting scene
  62465. * @param sceneLoadedCallback callback called when scene is loaded
  62466. * @param progressCallback callback called to track progress
  62467. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  62468. * @param textureLoadingCallback callback called when a texture is loading
  62469. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  62470. * @param onReloadCallback callback called when a reload is requested
  62471. * @param errorCallback callback call if an error occurs
  62472. */
  62473. 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);
  62474. private _dragEnterHandler;
  62475. private _dragOverHandler;
  62476. private _dropHandler;
  62477. /**
  62478. * Calls this function to listen to drag'n'drop events on a specific DOM element
  62479. * @param elementToMonitor defines the DOM element to track
  62480. */
  62481. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  62482. /**
  62483. * Release all associated resources
  62484. */
  62485. dispose(): void;
  62486. private renderFunction;
  62487. private drag;
  62488. private drop;
  62489. private _traverseFolder;
  62490. private _processFiles;
  62491. /**
  62492. * Load files from a drop event
  62493. * @param event defines the drop event to use as source
  62494. */
  62495. loadFiles(event: any): void;
  62496. private _processReload;
  62497. /**
  62498. * Reload the current scene from the loaded files
  62499. */
  62500. reload(): void;
  62501. }
  62502. }
  62503. declare module BABYLON {
  62504. /**
  62505. * Defines the root class used to create scene optimization to use with SceneOptimizer
  62506. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62507. */
  62508. export class SceneOptimization {
  62509. /**
  62510. * Defines the priority of this optimization (0 by default which means first in the list)
  62511. */
  62512. priority: number;
  62513. /**
  62514. * Gets a string describing the action executed by the current optimization
  62515. * @returns description string
  62516. */
  62517. getDescription(): string;
  62518. /**
  62519. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62520. * @param scene defines the current scene where to apply this optimization
  62521. * @param optimizer defines the current optimizer
  62522. * @returns true if everything that can be done was applied
  62523. */
  62524. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62525. /**
  62526. * Creates the SceneOptimization object
  62527. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62528. * @param desc defines the description associated with the optimization
  62529. */
  62530. constructor(
  62531. /**
  62532. * Defines the priority of this optimization (0 by default which means first in the list)
  62533. */
  62534. priority?: number);
  62535. }
  62536. /**
  62537. * Defines an optimization used to reduce the size of render target textures
  62538. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62539. */
  62540. export class TextureOptimization extends SceneOptimization {
  62541. /**
  62542. * Defines the priority of this optimization (0 by default which means first in the list)
  62543. */
  62544. priority: number;
  62545. /**
  62546. * 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
  62547. */
  62548. maximumSize: number;
  62549. /**
  62550. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62551. */
  62552. step: number;
  62553. /**
  62554. * Gets a string describing the action executed by the current optimization
  62555. * @returns description string
  62556. */
  62557. getDescription(): string;
  62558. /**
  62559. * Creates the TextureOptimization object
  62560. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62561. * @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
  62562. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62563. */
  62564. constructor(
  62565. /**
  62566. * Defines the priority of this optimization (0 by default which means first in the list)
  62567. */
  62568. priority?: number,
  62569. /**
  62570. * 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
  62571. */
  62572. maximumSize?: number,
  62573. /**
  62574. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62575. */
  62576. step?: number);
  62577. /**
  62578. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62579. * @param scene defines the current scene where to apply this optimization
  62580. * @param optimizer defines the current optimizer
  62581. * @returns true if everything that can be done was applied
  62582. */
  62583. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62584. }
  62585. /**
  62586. * Defines an optimization used to increase or decrease the rendering resolution
  62587. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62588. */
  62589. export class HardwareScalingOptimization extends SceneOptimization {
  62590. /**
  62591. * Defines the priority of this optimization (0 by default which means first in the list)
  62592. */
  62593. priority: number;
  62594. /**
  62595. * Defines the maximum scale to use (2 by default)
  62596. */
  62597. maximumScale: number;
  62598. /**
  62599. * Defines the step to use between two passes (0.5 by default)
  62600. */
  62601. step: number;
  62602. private _currentScale;
  62603. private _directionOffset;
  62604. /**
  62605. * Gets a string describing the action executed by the current optimization
  62606. * @return description string
  62607. */
  62608. getDescription(): string;
  62609. /**
  62610. * Creates the HardwareScalingOptimization object
  62611. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62612. * @param maximumScale defines the maximum scale to use (2 by default)
  62613. * @param step defines the step to use between two passes (0.5 by default)
  62614. */
  62615. constructor(
  62616. /**
  62617. * Defines the priority of this optimization (0 by default which means first in the list)
  62618. */
  62619. priority?: number,
  62620. /**
  62621. * Defines the maximum scale to use (2 by default)
  62622. */
  62623. maximumScale?: number,
  62624. /**
  62625. * Defines the step to use between two passes (0.5 by default)
  62626. */
  62627. step?: number);
  62628. /**
  62629. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62630. * @param scene defines the current scene where to apply this optimization
  62631. * @param optimizer defines the current optimizer
  62632. * @returns true if everything that can be done was applied
  62633. */
  62634. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62635. }
  62636. /**
  62637. * Defines an optimization used to remove shadows
  62638. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62639. */
  62640. export class ShadowsOptimization extends SceneOptimization {
  62641. /**
  62642. * Gets a string describing the action executed by the current optimization
  62643. * @return description string
  62644. */
  62645. getDescription(): string;
  62646. /**
  62647. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62648. * @param scene defines the current scene where to apply this optimization
  62649. * @param optimizer defines the current optimizer
  62650. * @returns true if everything that can be done was applied
  62651. */
  62652. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62653. }
  62654. /**
  62655. * Defines an optimization used to turn post-processes off
  62656. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62657. */
  62658. export class PostProcessesOptimization extends SceneOptimization {
  62659. /**
  62660. * Gets a string describing the action executed by the current optimization
  62661. * @return description string
  62662. */
  62663. getDescription(): string;
  62664. /**
  62665. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62666. * @param scene defines the current scene where to apply this optimization
  62667. * @param optimizer defines the current optimizer
  62668. * @returns true if everything that can be done was applied
  62669. */
  62670. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62671. }
  62672. /**
  62673. * Defines an optimization used to turn lens flares off
  62674. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62675. */
  62676. export class LensFlaresOptimization extends SceneOptimization {
  62677. /**
  62678. * Gets a string describing the action executed by the current optimization
  62679. * @return description string
  62680. */
  62681. getDescription(): string;
  62682. /**
  62683. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62684. * @param scene defines the current scene where to apply this optimization
  62685. * @param optimizer defines the current optimizer
  62686. * @returns true if everything that can be done was applied
  62687. */
  62688. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62689. }
  62690. /**
  62691. * Defines an optimization based on user defined callback.
  62692. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62693. */
  62694. export class CustomOptimization extends SceneOptimization {
  62695. /**
  62696. * Callback called to apply the custom optimization.
  62697. */
  62698. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  62699. /**
  62700. * Callback called to get custom description
  62701. */
  62702. onGetDescription: () => string;
  62703. /**
  62704. * Gets a string describing the action executed by the current optimization
  62705. * @returns description string
  62706. */
  62707. getDescription(): string;
  62708. /**
  62709. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62710. * @param scene defines the current scene where to apply this optimization
  62711. * @param optimizer defines the current optimizer
  62712. * @returns true if everything that can be done was applied
  62713. */
  62714. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62715. }
  62716. /**
  62717. * Defines an optimization used to turn particles off
  62718. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62719. */
  62720. export class ParticlesOptimization extends SceneOptimization {
  62721. /**
  62722. * Gets a string describing the action executed by the current optimization
  62723. * @return description string
  62724. */
  62725. getDescription(): string;
  62726. /**
  62727. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62728. * @param scene defines the current scene where to apply this optimization
  62729. * @param optimizer defines the current optimizer
  62730. * @returns true if everything that can be done was applied
  62731. */
  62732. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62733. }
  62734. /**
  62735. * Defines an optimization used to turn render targets off
  62736. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62737. */
  62738. export class RenderTargetsOptimization extends SceneOptimization {
  62739. /**
  62740. * Gets a string describing the action executed by the current optimization
  62741. * @return description string
  62742. */
  62743. getDescription(): string;
  62744. /**
  62745. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62746. * @param scene defines the current scene where to apply this optimization
  62747. * @param optimizer defines the current optimizer
  62748. * @returns true if everything that can be done was applied
  62749. */
  62750. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62751. }
  62752. /**
  62753. * Defines an optimization used to merge meshes with compatible materials
  62754. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62755. */
  62756. export class MergeMeshesOptimization extends SceneOptimization {
  62757. private static _UpdateSelectionTree;
  62758. /**
  62759. * Gets or sets a boolean which defines if optimization octree has to be updated
  62760. */
  62761. /**
  62762. * Gets or sets a boolean which defines if optimization octree has to be updated
  62763. */
  62764. static UpdateSelectionTree: boolean;
  62765. /**
  62766. * Gets a string describing the action executed by the current optimization
  62767. * @return description string
  62768. */
  62769. getDescription(): string;
  62770. private _canBeMerged;
  62771. /**
  62772. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62773. * @param scene defines the current scene where to apply this optimization
  62774. * @param optimizer defines the current optimizer
  62775. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  62776. * @returns true if everything that can be done was applied
  62777. */
  62778. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  62779. }
  62780. /**
  62781. * Defines a list of options used by SceneOptimizer
  62782. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62783. */
  62784. export class SceneOptimizerOptions {
  62785. /**
  62786. * Defines the target frame rate to reach (60 by default)
  62787. */
  62788. targetFrameRate: number;
  62789. /**
  62790. * Defines the interval between two checkes (2000ms by default)
  62791. */
  62792. trackerDuration: number;
  62793. /**
  62794. * Gets the list of optimizations to apply
  62795. */
  62796. optimizations: SceneOptimization[];
  62797. /**
  62798. * Creates a new list of options used by SceneOptimizer
  62799. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  62800. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  62801. */
  62802. constructor(
  62803. /**
  62804. * Defines the target frame rate to reach (60 by default)
  62805. */
  62806. targetFrameRate?: number,
  62807. /**
  62808. * Defines the interval between two checkes (2000ms by default)
  62809. */
  62810. trackerDuration?: number);
  62811. /**
  62812. * Add a new optimization
  62813. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62814. * @returns the current SceneOptimizerOptions
  62815. */
  62816. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62817. /**
  62818. * Add a new custom optimization
  62819. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62820. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62821. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62822. * @returns the current SceneOptimizerOptions
  62823. */
  62824. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62825. /**
  62826. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62827. * @param targetFrameRate defines the target frame rate (60 by default)
  62828. * @returns a SceneOptimizerOptions object
  62829. */
  62830. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62831. /**
  62832. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62833. * @param targetFrameRate defines the target frame rate (60 by default)
  62834. * @returns a SceneOptimizerOptions object
  62835. */
  62836. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62837. /**
  62838. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62839. * @param targetFrameRate defines the target frame rate (60 by default)
  62840. * @returns a SceneOptimizerOptions object
  62841. */
  62842. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62843. }
  62844. /**
  62845. * Class used to run optimizations in order to reach a target frame rate
  62846. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62847. */
  62848. export class SceneOptimizer implements IDisposable {
  62849. private _isRunning;
  62850. private _options;
  62851. private _scene;
  62852. private _currentPriorityLevel;
  62853. private _targetFrameRate;
  62854. private _trackerDuration;
  62855. private _currentFrameRate;
  62856. private _sceneDisposeObserver;
  62857. private _improvementMode;
  62858. /**
  62859. * Defines an observable called when the optimizer reaches the target frame rate
  62860. */
  62861. onSuccessObservable: Observable<SceneOptimizer>;
  62862. /**
  62863. * Defines an observable called when the optimizer enables an optimization
  62864. */
  62865. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62866. /**
  62867. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62868. */
  62869. onFailureObservable: Observable<SceneOptimizer>;
  62870. /**
  62871. * Gets a boolean indicating if the optimizer is in improvement mode
  62872. */
  62873. readonly isInImprovementMode: boolean;
  62874. /**
  62875. * Gets the current priority level (0 at start)
  62876. */
  62877. readonly currentPriorityLevel: number;
  62878. /**
  62879. * Gets the current frame rate checked by the SceneOptimizer
  62880. */
  62881. readonly currentFrameRate: number;
  62882. /**
  62883. * Gets or sets the current target frame rate (60 by default)
  62884. */
  62885. /**
  62886. * Gets or sets the current target frame rate (60 by default)
  62887. */
  62888. targetFrameRate: number;
  62889. /**
  62890. * Gets or sets the current interval between two checks (every 2000ms by default)
  62891. */
  62892. /**
  62893. * Gets or sets the current interval between two checks (every 2000ms by default)
  62894. */
  62895. trackerDuration: number;
  62896. /**
  62897. * Gets the list of active optimizations
  62898. */
  62899. readonly optimizations: SceneOptimization[];
  62900. /**
  62901. * Creates a new SceneOptimizer
  62902. * @param scene defines the scene to work on
  62903. * @param options defines the options to use with the SceneOptimizer
  62904. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62905. * @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)
  62906. */
  62907. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62908. /**
  62909. * Stops the current optimizer
  62910. */
  62911. stop(): void;
  62912. /**
  62913. * Reset the optimizer to initial step (current priority level = 0)
  62914. */
  62915. reset(): void;
  62916. /**
  62917. * Start the optimizer. By default it will try to reach a specific framerate
  62918. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62919. */
  62920. start(): void;
  62921. private _checkCurrentState;
  62922. /**
  62923. * Release all resources
  62924. */
  62925. dispose(): void;
  62926. /**
  62927. * Helper function to create a SceneOptimizer with one single line of code
  62928. * @param scene defines the scene to work on
  62929. * @param options defines the options to use with the SceneOptimizer
  62930. * @param onSuccess defines a callback to call on success
  62931. * @param onFailure defines a callback to call on failure
  62932. * @returns the new SceneOptimizer object
  62933. */
  62934. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62935. }
  62936. }
  62937. declare module BABYLON {
  62938. /**
  62939. * Class used to serialize a scene into a string
  62940. */
  62941. export class SceneSerializer {
  62942. /**
  62943. * Clear cache used by a previous serialization
  62944. */
  62945. static ClearCache(): void;
  62946. /**
  62947. * Serialize a scene into a JSON compatible object
  62948. * @param scene defines the scene to serialize
  62949. * @returns a JSON compatible object
  62950. */
  62951. static Serialize(scene: Scene): any;
  62952. /**
  62953. * Serialize a mesh into a JSON compatible object
  62954. * @param toSerialize defines the mesh to serialize
  62955. * @param withParents defines if parents must be serialized as well
  62956. * @param withChildren defines if children must be serialized as well
  62957. * @returns a JSON compatible object
  62958. */
  62959. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62960. }
  62961. }
  62962. declare module BABYLON {
  62963. /**
  62964. * Class used to host texture specific utilities
  62965. */
  62966. export class TextureTools {
  62967. /**
  62968. * Uses the GPU to create a copy texture rescaled at a given size
  62969. * @param texture Texture to copy from
  62970. * @param width defines the desired width
  62971. * @param height defines the desired height
  62972. * @param useBilinearMode defines if bilinear mode has to be used
  62973. * @return the generated texture
  62974. */
  62975. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62976. }
  62977. }
  62978. declare module BABYLON {
  62979. /**
  62980. * This represents the different options available for the video capture.
  62981. */
  62982. export interface VideoRecorderOptions {
  62983. /** Defines the mime type of the video. */
  62984. mimeType: string;
  62985. /** Defines the FPS the video should be recorded at. */
  62986. fps: number;
  62987. /** Defines the chunk size for the recording data. */
  62988. recordChunckSize: number;
  62989. /** The audio tracks to attach to the recording. */
  62990. audioTracks?: MediaStreamTrack[];
  62991. }
  62992. /**
  62993. * This can help with recording videos from BabylonJS.
  62994. * This is based on the available WebRTC functionalities of the browser.
  62995. *
  62996. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62997. */
  62998. export class VideoRecorder {
  62999. private static readonly _defaultOptions;
  63000. /**
  63001. * Returns whether or not the VideoRecorder is available in your browser.
  63002. * @param engine Defines the Babylon Engine.
  63003. * @returns true if supported otherwise false.
  63004. */
  63005. static IsSupported(engine: Engine): boolean;
  63006. private readonly _options;
  63007. private _canvas;
  63008. private _mediaRecorder;
  63009. private _recordedChunks;
  63010. private _fileName;
  63011. private _resolve;
  63012. private _reject;
  63013. /**
  63014. * True when a recording is already in progress.
  63015. */
  63016. readonly isRecording: boolean;
  63017. /**
  63018. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  63019. * @param engine Defines the BabylonJS Engine you wish to record.
  63020. * @param options Defines options that can be used to customize the capture.
  63021. */
  63022. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  63023. /**
  63024. * Stops the current recording before the default capture timeout passed in the startRecording function.
  63025. */
  63026. stopRecording(): void;
  63027. /**
  63028. * Starts recording the canvas for a max duration specified in parameters.
  63029. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  63030. * If null no automatic download will start and you can rely on the promise to get the data back.
  63031. * @param maxDuration Defines the maximum recording time in seconds.
  63032. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  63033. * @return A promise callback at the end of the recording with the video data in Blob.
  63034. */
  63035. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  63036. /**
  63037. * Releases internal resources used during the recording.
  63038. */
  63039. dispose(): void;
  63040. private _handleDataAvailable;
  63041. private _handleError;
  63042. private _handleStop;
  63043. }
  63044. }
  63045. declare module BABYLON {
  63046. /**
  63047. * Class containing a set of static utilities functions for screenshots
  63048. */
  63049. export class ScreenshotTools {
  63050. /**
  63051. * Captures a screenshot of the current rendering
  63052. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63053. * @param engine defines the rendering engine
  63054. * @param camera defines the source camera
  63055. * @param size This parameter can be set to a single number or to an object with the
  63056. * following (optional) properties: precision, width, height. If a single number is passed,
  63057. * it will be used for both width and height. If an object is passed, the screenshot size
  63058. * will be derived from the parameters. The precision property is a multiplier allowing
  63059. * rendering at a higher or lower resolution
  63060. * @param successCallback defines the callback receives a single parameter which contains the
  63061. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63062. * src parameter of an <img> to display it
  63063. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63064. * Check your browser for supported MIME types
  63065. */
  63066. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  63067. /**
  63068. * Captures a screenshot of the current rendering
  63069. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63070. * @param engine defines the rendering engine
  63071. * @param camera defines the source camera
  63072. * @param size This parameter can be set to a single number or to an object with the
  63073. * following (optional) properties: precision, width, height. If a single number is passed,
  63074. * it will be used for both width and height. If an object is passed, the screenshot size
  63075. * will be derived from the parameters. The precision property is a multiplier allowing
  63076. * rendering at a higher or lower resolution
  63077. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63078. * Check your browser for supported MIME types
  63079. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63080. * to the src parameter of an <img> to display it
  63081. */
  63082. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  63083. /**
  63084. * Generates an image screenshot from the specified camera.
  63085. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63086. * @param engine The engine to use for rendering
  63087. * @param camera The camera to use for rendering
  63088. * @param size This parameter can be set to a single number or to an object with the
  63089. * following (optional) properties: precision, width, height. If a single number is passed,
  63090. * it will be used for both width and height. If an object is passed, the screenshot size
  63091. * will be derived from the parameters. The precision property is a multiplier allowing
  63092. * rendering at a higher or lower resolution
  63093. * @param successCallback The callback receives a single parameter which contains the
  63094. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63095. * src parameter of an <img> to display it
  63096. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63097. * Check your browser for supported MIME types
  63098. * @param samples Texture samples (default: 1)
  63099. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63100. * @param fileName A name for for the downloaded file.
  63101. */
  63102. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  63103. /**
  63104. * Generates an image screenshot from the specified camera.
  63105. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63106. * @param engine The engine to use for rendering
  63107. * @param camera The camera to use for rendering
  63108. * @param size This parameter can be set to a single number or to an object with the
  63109. * following (optional) properties: precision, width, height. If a single number is passed,
  63110. * it will be used for both width and height. If an object is passed, the screenshot size
  63111. * will be derived from the parameters. The precision property is a multiplier allowing
  63112. * rendering at a higher or lower resolution
  63113. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63114. * Check your browser for supported MIME types
  63115. * @param samples Texture samples (default: 1)
  63116. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63117. * @param fileName A name for for the downloaded file.
  63118. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63119. * to the src parameter of an <img> to display it
  63120. */
  63121. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  63122. /**
  63123. * Gets height and width for screenshot size
  63124. * @private
  63125. */
  63126. private static _getScreenshotSize;
  63127. }
  63128. }
  63129. declare module BABYLON {
  63130. /**
  63131. * A cursor which tracks a point on a path
  63132. */
  63133. export class PathCursor {
  63134. private path;
  63135. /**
  63136. * Stores path cursor callbacks for when an onchange event is triggered
  63137. */
  63138. private _onchange;
  63139. /**
  63140. * The value of the path cursor
  63141. */
  63142. value: number;
  63143. /**
  63144. * The animation array of the path cursor
  63145. */
  63146. animations: Animation[];
  63147. /**
  63148. * Initializes the path cursor
  63149. * @param path The path to track
  63150. */
  63151. constructor(path: Path2);
  63152. /**
  63153. * Gets the cursor point on the path
  63154. * @returns A point on the path cursor at the cursor location
  63155. */
  63156. getPoint(): Vector3;
  63157. /**
  63158. * Moves the cursor ahead by the step amount
  63159. * @param step The amount to move the cursor forward
  63160. * @returns This path cursor
  63161. */
  63162. moveAhead(step?: number): PathCursor;
  63163. /**
  63164. * Moves the cursor behind by the step amount
  63165. * @param step The amount to move the cursor back
  63166. * @returns This path cursor
  63167. */
  63168. moveBack(step?: number): PathCursor;
  63169. /**
  63170. * Moves the cursor by the step amount
  63171. * If the step amount is greater than one, an exception is thrown
  63172. * @param step The amount to move the cursor
  63173. * @returns This path cursor
  63174. */
  63175. move(step: number): PathCursor;
  63176. /**
  63177. * Ensures that the value is limited between zero and one
  63178. * @returns This path cursor
  63179. */
  63180. private ensureLimits;
  63181. /**
  63182. * Runs onchange callbacks on change (used by the animation engine)
  63183. * @returns This path cursor
  63184. */
  63185. private raiseOnChange;
  63186. /**
  63187. * Executes a function on change
  63188. * @param f A path cursor onchange callback
  63189. * @returns This path cursor
  63190. */
  63191. onchange(f: (cursor: PathCursor) => void): PathCursor;
  63192. }
  63193. }
  63194. declare module BABYLON {
  63195. /** @hidden */
  63196. export var blurPixelShader: {
  63197. name: string;
  63198. shader: string;
  63199. };
  63200. }
  63201. declare module BABYLON {
  63202. /** @hidden */
  63203. export var pointCloudVertexDeclaration: {
  63204. name: string;
  63205. shader: string;
  63206. };
  63207. }
  63208. // Mixins
  63209. interface Window {
  63210. mozIndexedDB: IDBFactory;
  63211. webkitIndexedDB: IDBFactory;
  63212. msIndexedDB: IDBFactory;
  63213. webkitURL: typeof URL;
  63214. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  63215. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  63216. WebGLRenderingContext: WebGLRenderingContext;
  63217. MSGesture: MSGesture;
  63218. CANNON: any;
  63219. AudioContext: AudioContext;
  63220. webkitAudioContext: AudioContext;
  63221. PointerEvent: any;
  63222. Math: Math;
  63223. Uint8Array: Uint8ArrayConstructor;
  63224. Float32Array: Float32ArrayConstructor;
  63225. mozURL: typeof URL;
  63226. msURL: typeof URL;
  63227. VRFrameData: any; // WebVR, from specs 1.1
  63228. DracoDecoderModule: any;
  63229. setImmediate(handler: (...args: any[]) => void): number;
  63230. }
  63231. interface HTMLCanvasElement {
  63232. requestPointerLock(): void;
  63233. msRequestPointerLock?(): void;
  63234. mozRequestPointerLock?(): void;
  63235. webkitRequestPointerLock?(): void;
  63236. /** Track wether a record is in progress */
  63237. isRecording: boolean;
  63238. /** Capture Stream method defined by some browsers */
  63239. captureStream(fps?: number): MediaStream;
  63240. }
  63241. interface CanvasRenderingContext2D {
  63242. msImageSmoothingEnabled: boolean;
  63243. }
  63244. interface MouseEvent {
  63245. mozMovementX: number;
  63246. mozMovementY: number;
  63247. webkitMovementX: number;
  63248. webkitMovementY: number;
  63249. msMovementX: number;
  63250. msMovementY: number;
  63251. }
  63252. interface Navigator {
  63253. mozGetVRDevices: (any: any) => any;
  63254. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63255. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63256. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63257. webkitGetGamepads(): Gamepad[];
  63258. msGetGamepads(): Gamepad[];
  63259. webkitGamepads(): Gamepad[];
  63260. }
  63261. interface HTMLVideoElement {
  63262. mozSrcObject: any;
  63263. }
  63264. interface Math {
  63265. fround(x: number): number;
  63266. imul(a: number, b: number): number;
  63267. }
  63268. interface WebGLRenderingContext {
  63269. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  63270. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  63271. vertexAttribDivisor(index: number, divisor: number): void;
  63272. createVertexArray(): any;
  63273. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  63274. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  63275. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  63276. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  63277. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  63278. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  63279. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  63280. // Queries
  63281. createQuery(): WebGLQuery;
  63282. deleteQuery(query: WebGLQuery): void;
  63283. beginQuery(target: number, query: WebGLQuery): void;
  63284. endQuery(target: number): void;
  63285. getQueryParameter(query: WebGLQuery, pname: number): any;
  63286. getQuery(target: number, pname: number): any;
  63287. MAX_SAMPLES: number;
  63288. RGBA8: number;
  63289. READ_FRAMEBUFFER: number;
  63290. DRAW_FRAMEBUFFER: number;
  63291. UNIFORM_BUFFER: number;
  63292. HALF_FLOAT_OES: number;
  63293. RGBA16F: number;
  63294. RGBA32F: number;
  63295. R32F: number;
  63296. RG32F: number;
  63297. RGB32F: number;
  63298. R16F: number;
  63299. RG16F: number;
  63300. RGB16F: number;
  63301. RED: number;
  63302. RG: number;
  63303. R8: number;
  63304. RG8: number;
  63305. UNSIGNED_INT_24_8: number;
  63306. DEPTH24_STENCIL8: number;
  63307. MIN: number;
  63308. MAX: number;
  63309. /* Multiple Render Targets */
  63310. drawBuffers(buffers: number[]): void;
  63311. readBuffer(src: number): void;
  63312. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  63313. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  63314. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  63315. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  63316. // Occlusion Query
  63317. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  63318. ANY_SAMPLES_PASSED: number;
  63319. QUERY_RESULT_AVAILABLE: number;
  63320. QUERY_RESULT: number;
  63321. }
  63322. interface WebGLProgram {
  63323. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  63324. }
  63325. interface EXT_disjoint_timer_query {
  63326. QUERY_COUNTER_BITS_EXT: number;
  63327. TIME_ELAPSED_EXT: number;
  63328. TIMESTAMP_EXT: number;
  63329. GPU_DISJOINT_EXT: number;
  63330. QUERY_RESULT_EXT: number;
  63331. QUERY_RESULT_AVAILABLE_EXT: number;
  63332. queryCounterEXT(query: WebGLQuery, target: number): void;
  63333. createQueryEXT(): WebGLQuery;
  63334. beginQueryEXT(target: number, query: WebGLQuery): void;
  63335. endQueryEXT(target: number): void;
  63336. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  63337. deleteQueryEXT(query: WebGLQuery): void;
  63338. }
  63339. interface WebGLUniformLocation {
  63340. _currentState: any;
  63341. }
  63342. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  63343. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  63344. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  63345. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63346. interface WebGLRenderingContext {
  63347. readonly RASTERIZER_DISCARD: number;
  63348. readonly DEPTH_COMPONENT24: number;
  63349. readonly TEXTURE_3D: number;
  63350. readonly TEXTURE_2D_ARRAY: number;
  63351. readonly TEXTURE_COMPARE_FUNC: number;
  63352. readonly TEXTURE_COMPARE_MODE: number;
  63353. readonly COMPARE_REF_TO_TEXTURE: number;
  63354. readonly TEXTURE_WRAP_R: number;
  63355. readonly HALF_FLOAT: number;
  63356. readonly RGB8: number;
  63357. readonly RED_INTEGER: number;
  63358. readonly RG_INTEGER: number;
  63359. readonly RGB_INTEGER: number;
  63360. readonly RGBA_INTEGER: number;
  63361. readonly R8_SNORM: number;
  63362. readonly RG8_SNORM: number;
  63363. readonly RGB8_SNORM: number;
  63364. readonly RGBA8_SNORM: number;
  63365. readonly R8I: number;
  63366. readonly RG8I: number;
  63367. readonly RGB8I: number;
  63368. readonly RGBA8I: number;
  63369. readonly R8UI: number;
  63370. readonly RG8UI: number;
  63371. readonly RGB8UI: number;
  63372. readonly RGBA8UI: number;
  63373. readonly R16I: number;
  63374. readonly RG16I: number;
  63375. readonly RGB16I: number;
  63376. readonly RGBA16I: number;
  63377. readonly R16UI: number;
  63378. readonly RG16UI: number;
  63379. readonly RGB16UI: number;
  63380. readonly RGBA16UI: number;
  63381. readonly R32I: number;
  63382. readonly RG32I: number;
  63383. readonly RGB32I: number;
  63384. readonly RGBA32I: number;
  63385. readonly R32UI: number;
  63386. readonly RG32UI: number;
  63387. readonly RGB32UI: number;
  63388. readonly RGBA32UI: number;
  63389. readonly RGB10_A2UI: number;
  63390. readonly R11F_G11F_B10F: number;
  63391. readonly RGB9_E5: number;
  63392. readonly RGB10_A2: number;
  63393. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  63394. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  63395. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  63396. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63397. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  63398. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  63399. 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;
  63400. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  63401. readonly TRANSFORM_FEEDBACK: number;
  63402. readonly INTERLEAVED_ATTRIBS: number;
  63403. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  63404. createTransformFeedback(): WebGLTransformFeedback;
  63405. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  63406. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  63407. beginTransformFeedback(primitiveMode: number): void;
  63408. endTransformFeedback(): void;
  63409. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  63410. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63411. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63412. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63413. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  63414. }
  63415. interface ImageBitmap {
  63416. readonly width: number;
  63417. readonly height: number;
  63418. close(): void;
  63419. }
  63420. interface WebGLQuery extends WebGLObject {
  63421. }
  63422. declare var WebGLQuery: {
  63423. prototype: WebGLQuery;
  63424. new(): WebGLQuery;
  63425. };
  63426. interface WebGLSampler extends WebGLObject {
  63427. }
  63428. declare var WebGLSampler: {
  63429. prototype: WebGLSampler;
  63430. new(): WebGLSampler;
  63431. };
  63432. interface WebGLSync extends WebGLObject {
  63433. }
  63434. declare var WebGLSync: {
  63435. prototype: WebGLSync;
  63436. new(): WebGLSync;
  63437. };
  63438. interface WebGLTransformFeedback extends WebGLObject {
  63439. }
  63440. declare var WebGLTransformFeedback: {
  63441. prototype: WebGLTransformFeedback;
  63442. new(): WebGLTransformFeedback;
  63443. };
  63444. interface WebGLVertexArrayObject extends WebGLObject {
  63445. }
  63446. declare var WebGLVertexArrayObject: {
  63447. prototype: WebGLVertexArrayObject;
  63448. new(): WebGLVertexArrayObject;
  63449. };
  63450. // Type definitions for WebVR API
  63451. // Project: https://w3c.github.io/webvr/
  63452. // Definitions by: six a <https://github.com/lostfictions>
  63453. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63454. interface VRDisplay extends EventTarget {
  63455. /**
  63456. * Dictionary of capabilities describing the VRDisplay.
  63457. */
  63458. readonly capabilities: VRDisplayCapabilities;
  63459. /**
  63460. * z-depth defining the far plane of the eye view frustum
  63461. * enables mapping of values in the render target depth
  63462. * attachment to scene coordinates. Initially set to 10000.0.
  63463. */
  63464. depthFar: number;
  63465. /**
  63466. * z-depth defining the near plane of the eye view frustum
  63467. * enables mapping of values in the render target depth
  63468. * attachment to scene coordinates. Initially set to 0.01.
  63469. */
  63470. depthNear: number;
  63471. /**
  63472. * An identifier for this distinct VRDisplay. Used as an
  63473. * association point in the Gamepad API.
  63474. */
  63475. readonly displayId: number;
  63476. /**
  63477. * A display name, a user-readable name identifying it.
  63478. */
  63479. readonly displayName: string;
  63480. readonly isConnected: boolean;
  63481. readonly isPresenting: boolean;
  63482. /**
  63483. * If this VRDisplay supports room-scale experiences, the optional
  63484. * stage attribute contains details on the room-scale parameters.
  63485. */
  63486. readonly stageParameters: VRStageParameters | null;
  63487. /**
  63488. * Passing the value returned by `requestAnimationFrame` to
  63489. * `cancelAnimationFrame` will unregister the callback.
  63490. * @param handle Define the hanle of the request to cancel
  63491. */
  63492. cancelAnimationFrame(handle: number): void;
  63493. /**
  63494. * Stops presenting to the VRDisplay.
  63495. * @returns a promise to know when it stopped
  63496. */
  63497. exitPresent(): Promise<void>;
  63498. /**
  63499. * Return the current VREyeParameters for the given eye.
  63500. * @param whichEye Define the eye we want the parameter for
  63501. * @returns the eye parameters
  63502. */
  63503. getEyeParameters(whichEye: string): VREyeParameters;
  63504. /**
  63505. * Populates the passed VRFrameData with the information required to render
  63506. * the current frame.
  63507. * @param frameData Define the data structure to populate
  63508. * @returns true if ok otherwise false
  63509. */
  63510. getFrameData(frameData: VRFrameData): boolean;
  63511. /**
  63512. * Get the layers currently being presented.
  63513. * @returns the list of VR layers
  63514. */
  63515. getLayers(): VRLayer[];
  63516. /**
  63517. * Return a VRPose containing the future predicted pose of the VRDisplay
  63518. * when the current frame will be presented. The value returned will not
  63519. * change until JavaScript has returned control to the browser.
  63520. *
  63521. * The VRPose will contain the position, orientation, velocity,
  63522. * and acceleration of each of these properties.
  63523. * @returns the pose object
  63524. */
  63525. getPose(): VRPose;
  63526. /**
  63527. * Return the current instantaneous pose of the VRDisplay, with no
  63528. * prediction applied.
  63529. * @returns the current instantaneous pose
  63530. */
  63531. getImmediatePose(): VRPose;
  63532. /**
  63533. * The callback passed to `requestAnimationFrame` will be called
  63534. * any time a new frame should be rendered. When the VRDisplay is
  63535. * presenting the callback will be called at the native refresh
  63536. * rate of the HMD. When not presenting this function acts
  63537. * identically to how window.requestAnimationFrame acts. Content should
  63538. * make no assumptions of frame rate or vsync behavior as the HMD runs
  63539. * asynchronously from other displays and at differing refresh rates.
  63540. * @param callback Define the eaction to run next frame
  63541. * @returns the request handle it
  63542. */
  63543. requestAnimationFrame(callback: FrameRequestCallback): number;
  63544. /**
  63545. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  63546. * Repeat calls while already presenting will update the VRLayers being displayed.
  63547. * @param layers Define the list of layer to present
  63548. * @returns a promise to know when the request has been fulfilled
  63549. */
  63550. requestPresent(layers: VRLayer[]): Promise<void>;
  63551. /**
  63552. * Reset the pose for this display, treating its current position and
  63553. * orientation as the "origin/zero" values. VRPose.position,
  63554. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  63555. * updated when calling resetPose(). This should be called in only
  63556. * sitting-space experiences.
  63557. */
  63558. resetPose(): void;
  63559. /**
  63560. * The VRLayer provided to the VRDisplay will be captured and presented
  63561. * in the HMD. Calling this function has the same effect on the source
  63562. * canvas as any other operation that uses its source image, and canvases
  63563. * created without preserveDrawingBuffer set to true will be cleared.
  63564. * @param pose Define the pose to submit
  63565. */
  63566. submitFrame(pose?: VRPose): void;
  63567. }
  63568. declare var VRDisplay: {
  63569. prototype: VRDisplay;
  63570. new(): VRDisplay;
  63571. };
  63572. interface VRLayer {
  63573. leftBounds?: number[] | Float32Array | null;
  63574. rightBounds?: number[] | Float32Array | null;
  63575. source?: HTMLCanvasElement | null;
  63576. }
  63577. interface VRDisplayCapabilities {
  63578. readonly canPresent: boolean;
  63579. readonly hasExternalDisplay: boolean;
  63580. readonly hasOrientation: boolean;
  63581. readonly hasPosition: boolean;
  63582. readonly maxLayers: number;
  63583. }
  63584. interface VREyeParameters {
  63585. /** @deprecated */
  63586. readonly fieldOfView: VRFieldOfView;
  63587. readonly offset: Float32Array;
  63588. readonly renderHeight: number;
  63589. readonly renderWidth: number;
  63590. }
  63591. interface VRFieldOfView {
  63592. readonly downDegrees: number;
  63593. readonly leftDegrees: number;
  63594. readonly rightDegrees: number;
  63595. readonly upDegrees: number;
  63596. }
  63597. interface VRFrameData {
  63598. readonly leftProjectionMatrix: Float32Array;
  63599. readonly leftViewMatrix: Float32Array;
  63600. readonly pose: VRPose;
  63601. readonly rightProjectionMatrix: Float32Array;
  63602. readonly rightViewMatrix: Float32Array;
  63603. readonly timestamp: number;
  63604. }
  63605. interface VRPose {
  63606. readonly angularAcceleration: Float32Array | null;
  63607. readonly angularVelocity: Float32Array | null;
  63608. readonly linearAcceleration: Float32Array | null;
  63609. readonly linearVelocity: Float32Array | null;
  63610. readonly orientation: Float32Array | null;
  63611. readonly position: Float32Array | null;
  63612. readonly timestamp: number;
  63613. }
  63614. interface VRStageParameters {
  63615. sittingToStandingTransform?: Float32Array;
  63616. sizeX?: number;
  63617. sizeY?: number;
  63618. }
  63619. interface Navigator {
  63620. getVRDisplays(): Promise<VRDisplay[]>;
  63621. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  63622. }
  63623. interface Window {
  63624. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  63625. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  63626. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  63627. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63628. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63629. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  63630. }
  63631. interface Gamepad {
  63632. readonly displayId: number;
  63633. }
  63634. type XRSessionMode =
  63635. | "inline"
  63636. | "immersive-vr"
  63637. | "immersive-ar";
  63638. type XRReferenceSpaceType =
  63639. | "viewer"
  63640. | "local"
  63641. | "local-floor"
  63642. | "bounded-floor"
  63643. | "unbounded";
  63644. type XREnvironmentBlendMode =
  63645. | "opaque"
  63646. | "additive"
  63647. | "alpha-blend";
  63648. type XRVisibilityState =
  63649. | "visible"
  63650. | "visible-blurred"
  63651. | "hidden";
  63652. type XRHandedness =
  63653. | "none"
  63654. | "left"
  63655. | "right";
  63656. type XRTargetRayMode =
  63657. | "gaze"
  63658. | "tracked-pointer"
  63659. | "screen";
  63660. type XREye =
  63661. | "none"
  63662. | "left"
  63663. | "right";
  63664. interface XRSpace extends EventTarget {
  63665. }
  63666. interface XRRenderState {
  63667. depthNear?: number;
  63668. depthFar?: number;
  63669. inlineVerticalFieldOfView?: number;
  63670. baseLayer?: XRWebGLLayer;
  63671. }
  63672. interface XRInputSource {
  63673. handedness: XRHandedness;
  63674. targetRayMode: XRTargetRayMode;
  63675. targetRaySpace: XRSpace;
  63676. gripSpace: XRSpace | undefined;
  63677. gamepad: Gamepad | undefined;
  63678. profiles: Array<string>;
  63679. }
  63680. interface XRSession {
  63681. addEventListener: Function;
  63682. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  63683. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  63684. requestAnimationFrame: Function;
  63685. end(): Promise<void>;
  63686. renderState: XRRenderState;
  63687. inputSources: Array<XRInputSource>;
  63688. }
  63689. interface XRReferenceSpace extends XRSpace {
  63690. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  63691. onreset: any;
  63692. }
  63693. interface XRFrame {
  63694. session: XRSession;
  63695. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  63696. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  63697. }
  63698. interface XRViewerPose extends XRPose {
  63699. views: Array<XRView>;
  63700. }
  63701. interface XRPose {
  63702. transform: XRRigidTransform;
  63703. emulatedPosition: boolean;
  63704. }
  63705. declare var XRWebGLLayer: {
  63706. prototype: XRWebGLLayer;
  63707. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  63708. };
  63709. interface XRWebGLLayer {
  63710. framebuffer: WebGLFramebuffer;
  63711. framebufferWidth: number;
  63712. framebufferHeight: number;
  63713. getViewport: Function;
  63714. }
  63715. interface XRRigidTransform {
  63716. position: DOMPointReadOnly;
  63717. orientation: DOMPointReadOnly;
  63718. matrix: Float32Array;
  63719. inverse: XRRigidTransform;
  63720. }
  63721. interface XRView {
  63722. eye: XREye;
  63723. projectionMatrix: Float32Array;
  63724. transform: XRRigidTransform;
  63725. }
  63726. interface XRInputSourceChangeEvent {
  63727. session: XRSession;
  63728. removed: Array<XRInputSource>;
  63729. added: Array<XRInputSource>;
  63730. }
  63731. /**
  63732. * @ignore
  63733. */
  63734. declare module BABYLON.GLTF2.Exporter {
  63735. }
  63736. /**
  63737. * @ignore
  63738. */
  63739. declare module BABYLON.GLTF1 {
  63740. }
  63741. declare module BABYLON.GUI {
  63742. /**
  63743. * Class used to specific a value and its associated unit
  63744. */
  63745. export class ValueAndUnit {
  63746. /** defines the unit to store */
  63747. unit: number;
  63748. /** defines a boolean indicating if the value can be negative */
  63749. negativeValueAllowed: boolean;
  63750. private _value;
  63751. private _originalUnit;
  63752. /**
  63753. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  63754. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63755. */
  63756. ignoreAdaptiveScaling: boolean;
  63757. /**
  63758. * Creates a new ValueAndUnit
  63759. * @param value defines the value to store
  63760. * @param unit defines the unit to store
  63761. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  63762. */
  63763. constructor(value: number,
  63764. /** defines the unit to store */
  63765. unit?: number,
  63766. /** defines a boolean indicating if the value can be negative */
  63767. negativeValueAllowed?: boolean);
  63768. /** Gets a boolean indicating if the value is a percentage */
  63769. readonly isPercentage: boolean;
  63770. /** Gets a boolean indicating if the value is store as pixel */
  63771. readonly isPixel: boolean;
  63772. /** Gets direct internal value */
  63773. readonly internalValue: number;
  63774. /**
  63775. * Gets value as pixel
  63776. * @param host defines the root host
  63777. * @param refValue defines the reference value for percentages
  63778. * @returns the value as pixel
  63779. */
  63780. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  63781. /**
  63782. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  63783. * @param value defines the value to store
  63784. * @param unit defines the unit to store
  63785. * @returns the current ValueAndUnit
  63786. */
  63787. updateInPlace(value: number, unit?: number): ValueAndUnit;
  63788. /**
  63789. * Gets the value accordingly to its unit
  63790. * @param host defines the root host
  63791. * @returns the value
  63792. */
  63793. getValue(host: AdvancedDynamicTexture): number;
  63794. /**
  63795. * Gets a string representation of the value
  63796. * @param host defines the root host
  63797. * @param decimals defines an optional number of decimals to display
  63798. * @returns a string
  63799. */
  63800. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  63801. /**
  63802. * Store a value parsed from a string
  63803. * @param source defines the source string
  63804. * @returns true if the value was successfully parsed
  63805. */
  63806. fromString(source: string | number): boolean;
  63807. private static _Regex;
  63808. private static _UNITMODE_PERCENTAGE;
  63809. private static _UNITMODE_PIXEL;
  63810. /** UNITMODE_PERCENTAGE */
  63811. static readonly UNITMODE_PERCENTAGE: number;
  63812. /** UNITMODE_PIXEL */
  63813. static readonly UNITMODE_PIXEL: number;
  63814. }
  63815. }
  63816. declare module BABYLON.GUI {
  63817. /**
  63818. * Define a style used by control to automatically setup properties based on a template.
  63819. * Only support font related properties so far
  63820. */
  63821. export class Style implements BABYLON.IDisposable {
  63822. private _fontFamily;
  63823. private _fontStyle;
  63824. private _fontWeight;
  63825. /** @hidden */
  63826. _host: AdvancedDynamicTexture;
  63827. /** @hidden */
  63828. _fontSize: ValueAndUnit;
  63829. /**
  63830. * BABYLON.Observable raised when the style values are changed
  63831. */
  63832. onChangedObservable: BABYLON.Observable<Style>;
  63833. /**
  63834. * Creates a new style object
  63835. * @param host defines the AdvancedDynamicTexture which hosts this style
  63836. */
  63837. constructor(host: AdvancedDynamicTexture);
  63838. /**
  63839. * Gets or sets the font size
  63840. */
  63841. fontSize: string | number;
  63842. /**
  63843. * Gets or sets the font family
  63844. */
  63845. fontFamily: string;
  63846. /**
  63847. * Gets or sets the font style
  63848. */
  63849. fontStyle: string;
  63850. /** Gets or sets font weight */
  63851. fontWeight: string;
  63852. /** Dispose all associated resources */
  63853. dispose(): void;
  63854. }
  63855. }
  63856. declare module BABYLON.GUI {
  63857. /**
  63858. * Class used to transport BABYLON.Vector2 information for pointer events
  63859. */
  63860. export class Vector2WithInfo extends BABYLON.Vector2 {
  63861. /** defines the current mouse button index */
  63862. buttonIndex: number;
  63863. /**
  63864. * Creates a new Vector2WithInfo
  63865. * @param source defines the vector2 data to transport
  63866. * @param buttonIndex defines the current mouse button index
  63867. */
  63868. constructor(source: BABYLON.Vector2,
  63869. /** defines the current mouse button index */
  63870. buttonIndex?: number);
  63871. }
  63872. /** Class used to provide 2D matrix features */
  63873. export class Matrix2D {
  63874. /** Gets the internal array of 6 floats used to store matrix data */
  63875. m: Float32Array;
  63876. /**
  63877. * Creates a new matrix
  63878. * @param m00 defines value for (0, 0)
  63879. * @param m01 defines value for (0, 1)
  63880. * @param m10 defines value for (1, 0)
  63881. * @param m11 defines value for (1, 1)
  63882. * @param m20 defines value for (2, 0)
  63883. * @param m21 defines value for (2, 1)
  63884. */
  63885. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  63886. /**
  63887. * Fills the matrix from direct values
  63888. * @param m00 defines value for (0, 0)
  63889. * @param m01 defines value for (0, 1)
  63890. * @param m10 defines value for (1, 0)
  63891. * @param m11 defines value for (1, 1)
  63892. * @param m20 defines value for (2, 0)
  63893. * @param m21 defines value for (2, 1)
  63894. * @returns the current modified matrix
  63895. */
  63896. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  63897. /**
  63898. * Gets matrix determinant
  63899. * @returns the determinant
  63900. */
  63901. determinant(): number;
  63902. /**
  63903. * Inverses the matrix and stores it in a target matrix
  63904. * @param result defines the target matrix
  63905. * @returns the current matrix
  63906. */
  63907. invertToRef(result: Matrix2D): Matrix2D;
  63908. /**
  63909. * Multiplies the current matrix with another one
  63910. * @param other defines the second operand
  63911. * @param result defines the target matrix
  63912. * @returns the current matrix
  63913. */
  63914. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  63915. /**
  63916. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  63917. * @param x defines the x coordinate to transform
  63918. * @param y defines the x coordinate to transform
  63919. * @param result defines the target vector2
  63920. * @returns the current matrix
  63921. */
  63922. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  63923. /**
  63924. * Creates an identity matrix
  63925. * @returns a new matrix
  63926. */
  63927. static Identity(): Matrix2D;
  63928. /**
  63929. * Creates a translation matrix and stores it in a target matrix
  63930. * @param x defines the x coordinate of the translation
  63931. * @param y defines the y coordinate of the translation
  63932. * @param result defines the target matrix
  63933. */
  63934. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  63935. /**
  63936. * Creates a scaling matrix and stores it in a target matrix
  63937. * @param x defines the x coordinate of the scaling
  63938. * @param y defines the y coordinate of the scaling
  63939. * @param result defines the target matrix
  63940. */
  63941. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  63942. /**
  63943. * Creates a rotation matrix and stores it in a target matrix
  63944. * @param angle defines the rotation angle
  63945. * @param result defines the target matrix
  63946. */
  63947. static RotationToRef(angle: number, result: Matrix2D): void;
  63948. private static _TempPreTranslationMatrix;
  63949. private static _TempPostTranslationMatrix;
  63950. private static _TempRotationMatrix;
  63951. private static _TempScalingMatrix;
  63952. private static _TempCompose0;
  63953. private static _TempCompose1;
  63954. private static _TempCompose2;
  63955. /**
  63956. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  63957. * @param tx defines the x coordinate of the translation
  63958. * @param ty defines the y coordinate of the translation
  63959. * @param angle defines the rotation angle
  63960. * @param scaleX defines the x coordinate of the scaling
  63961. * @param scaleY defines the y coordinate of the scaling
  63962. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  63963. * @param result defines the target matrix
  63964. */
  63965. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  63966. }
  63967. }
  63968. declare module BABYLON.GUI {
  63969. /**
  63970. * Class used to store 2D control sizes
  63971. */
  63972. export class Measure {
  63973. /** defines left coordinate */
  63974. left: number;
  63975. /** defines top coordinate */
  63976. top: number;
  63977. /** defines width dimension */
  63978. width: number;
  63979. /** defines height dimension */
  63980. height: number;
  63981. /**
  63982. * Creates a new measure
  63983. * @param left defines left coordinate
  63984. * @param top defines top coordinate
  63985. * @param width defines width dimension
  63986. * @param height defines height dimension
  63987. */
  63988. constructor(
  63989. /** defines left coordinate */
  63990. left: number,
  63991. /** defines top coordinate */
  63992. top: number,
  63993. /** defines width dimension */
  63994. width: number,
  63995. /** defines height dimension */
  63996. height: number);
  63997. /**
  63998. * Copy from another measure
  63999. * @param other defines the other measure to copy from
  64000. */
  64001. copyFrom(other: Measure): void;
  64002. /**
  64003. * Copy from a group of 4 floats
  64004. * @param left defines left coordinate
  64005. * @param top defines top coordinate
  64006. * @param width defines width dimension
  64007. * @param height defines height dimension
  64008. */
  64009. copyFromFloats(left: number, top: number, width: number, height: number): void;
  64010. /**
  64011. * Computes the axis aligned bounding box measure for two given measures
  64012. * @param a Input measure
  64013. * @param b Input measure
  64014. * @param result the resulting bounding measure
  64015. */
  64016. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  64017. /**
  64018. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  64019. * @param transform the matrix to transform the measure before computing the AABB
  64020. * @param result the resulting AABB
  64021. */
  64022. transformToRef(transform: Matrix2D, result: Measure): void;
  64023. /**
  64024. * Check equality between this measure and another one
  64025. * @param other defines the other measures
  64026. * @returns true if both measures are equals
  64027. */
  64028. isEqualsTo(other: Measure): boolean;
  64029. /**
  64030. * Creates an empty measure
  64031. * @returns a new measure
  64032. */
  64033. static Empty(): Measure;
  64034. }
  64035. }
  64036. declare module BABYLON.GUI {
  64037. /**
  64038. * Interface used to define a control that can receive focus
  64039. */
  64040. export interface IFocusableControl {
  64041. /**
  64042. * Function called when the control receives the focus
  64043. */
  64044. onFocus(): void;
  64045. /**
  64046. * Function called when the control loses the focus
  64047. */
  64048. onBlur(): void;
  64049. /**
  64050. * Function called to let the control handle keyboard events
  64051. * @param evt defines the current keyboard event
  64052. */
  64053. processKeyboard(evt: KeyboardEvent): void;
  64054. /**
  64055. * Function called to get the list of controls that should not steal the focus from this control
  64056. * @returns an array of controls
  64057. */
  64058. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64059. }
  64060. /**
  64061. * Class used to create texture to support 2D GUI elements
  64062. * @see http://doc.babylonjs.com/how_to/gui
  64063. */
  64064. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  64065. private _isDirty;
  64066. private _renderObserver;
  64067. private _resizeObserver;
  64068. private _preKeyboardObserver;
  64069. private _pointerMoveObserver;
  64070. private _pointerObserver;
  64071. private _canvasPointerOutObserver;
  64072. private _background;
  64073. /** @hidden */
  64074. _rootContainer: Container;
  64075. /** @hidden */
  64076. _lastPickedControl: Control;
  64077. /** @hidden */
  64078. _lastControlOver: {
  64079. [pointerId: number]: Control;
  64080. };
  64081. /** @hidden */
  64082. _lastControlDown: {
  64083. [pointerId: number]: Control;
  64084. };
  64085. /** @hidden */
  64086. _capturingControl: {
  64087. [pointerId: number]: Control;
  64088. };
  64089. /** @hidden */
  64090. _shouldBlockPointer: boolean;
  64091. /** @hidden */
  64092. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  64093. /** @hidden */
  64094. _linkedControls: Control[];
  64095. private _isFullscreen;
  64096. private _fullscreenViewport;
  64097. private _idealWidth;
  64098. private _idealHeight;
  64099. private _useSmallestIdeal;
  64100. private _renderAtIdealSize;
  64101. private _focusedControl;
  64102. private _blockNextFocusCheck;
  64103. private _renderScale;
  64104. private _rootCanvas;
  64105. private _cursorChanged;
  64106. /**
  64107. * Define type to string to ensure compatibility across browsers
  64108. * Safari doesn't support DataTransfer constructor
  64109. */
  64110. private _clipboardData;
  64111. /**
  64112. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  64113. */
  64114. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  64115. /**
  64116. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  64117. */
  64118. onControlPickedObservable: BABYLON.Observable<Control>;
  64119. /**
  64120. * BABYLON.Observable event triggered before layout is evaluated
  64121. */
  64122. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64123. /**
  64124. * BABYLON.Observable event triggered after the layout was evaluated
  64125. */
  64126. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64127. /**
  64128. * BABYLON.Observable event triggered before the texture is rendered
  64129. */
  64130. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64131. /**
  64132. * BABYLON.Observable event triggered after the texture was rendered
  64133. */
  64134. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64135. /**
  64136. * Gets or sets a boolean defining if alpha is stored as premultiplied
  64137. */
  64138. premulAlpha: boolean;
  64139. /**
  64140. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  64141. * Useful when you want more antialiasing
  64142. */
  64143. renderScale: number;
  64144. /** Gets or sets the background color */
  64145. background: string;
  64146. /**
  64147. * Gets or sets the ideal width used to design controls.
  64148. * The GUI will then rescale everything accordingly
  64149. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64150. */
  64151. idealWidth: number;
  64152. /**
  64153. * Gets or sets the ideal height used to design controls.
  64154. * The GUI will then rescale everything accordingly
  64155. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64156. */
  64157. idealHeight: number;
  64158. /**
  64159. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  64160. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64161. */
  64162. useSmallestIdeal: boolean;
  64163. /**
  64164. * Gets or sets a boolean indicating if adaptive scaling must be used
  64165. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64166. */
  64167. renderAtIdealSize: boolean;
  64168. /**
  64169. * Gets the underlying layer used to render the texture when in fullscreen mode
  64170. */
  64171. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  64172. /**
  64173. * Gets the root container control
  64174. */
  64175. readonly rootContainer: Container;
  64176. /**
  64177. * Returns an array containing the root container.
  64178. * This is mostly used to let the Inspector introspects the ADT
  64179. * @returns an array containing the rootContainer
  64180. */
  64181. getChildren(): Array<Container>;
  64182. /**
  64183. * Will return all controls that are inside this texture
  64184. * @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
  64185. * @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
  64186. * @return all child controls
  64187. */
  64188. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64189. /**
  64190. * Gets or sets the current focused control
  64191. */
  64192. focusedControl: BABYLON.Nullable<IFocusableControl>;
  64193. /**
  64194. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  64195. */
  64196. isForeground: boolean;
  64197. /**
  64198. * Gets or set information about clipboardData
  64199. */
  64200. clipboardData: string;
  64201. /**
  64202. * Creates a new AdvancedDynamicTexture
  64203. * @param name defines the name of the texture
  64204. * @param width defines the width of the texture
  64205. * @param height defines the height of the texture
  64206. * @param scene defines the hosting scene
  64207. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  64208. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  64209. */
  64210. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  64211. /**
  64212. * Get the current class name of the texture useful for serialization or dynamic coding.
  64213. * @returns "AdvancedDynamicTexture"
  64214. */
  64215. getClassName(): string;
  64216. /**
  64217. * Function used to execute a function on all controls
  64218. * @param func defines the function to execute
  64219. * @param container defines the container where controls belong. If null the root container will be used
  64220. */
  64221. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  64222. private _useInvalidateRectOptimization;
  64223. /**
  64224. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  64225. */
  64226. useInvalidateRectOptimization: boolean;
  64227. private _invalidatedRectangle;
  64228. /**
  64229. * Invalidates a rectangle area on the gui texture
  64230. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  64231. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  64232. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  64233. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  64234. */
  64235. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  64236. /**
  64237. * Marks the texture as dirty forcing a complete update
  64238. */
  64239. markAsDirty(): void;
  64240. /**
  64241. * Helper function used to create a new style
  64242. * @returns a new style
  64243. * @see http://doc.babylonjs.com/how_to/gui#styles
  64244. */
  64245. createStyle(): Style;
  64246. /**
  64247. * Adds a new control to the root container
  64248. * @param control defines the control to add
  64249. * @returns the current texture
  64250. */
  64251. addControl(control: Control): AdvancedDynamicTexture;
  64252. /**
  64253. * Removes a control from the root container
  64254. * @param control defines the control to remove
  64255. * @returns the current texture
  64256. */
  64257. removeControl(control: Control): AdvancedDynamicTexture;
  64258. /**
  64259. * Release all resources
  64260. */
  64261. dispose(): void;
  64262. private _onResize;
  64263. /** @hidden */
  64264. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  64265. /**
  64266. * Get screen coordinates for a vector3
  64267. * @param position defines the position to project
  64268. * @param worldMatrix defines the world matrix to use
  64269. * @returns the projected position
  64270. */
  64271. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  64272. private _checkUpdate;
  64273. private _clearMeasure;
  64274. private _render;
  64275. /** @hidden */
  64276. _changeCursor(cursor: string): void;
  64277. /** @hidden */
  64278. _registerLastControlDown(control: Control, pointerId: number): void;
  64279. private _doPicking;
  64280. /** @hidden */
  64281. _cleanControlAfterRemovalFromList(list: {
  64282. [pointerId: number]: Control;
  64283. }, control: Control): void;
  64284. /** @hidden */
  64285. _cleanControlAfterRemoval(control: Control): void;
  64286. /** Attach to all scene events required to support pointer events */
  64287. attach(): void;
  64288. /** @hidden */
  64289. private onClipboardCopy;
  64290. /** @hidden */
  64291. private onClipboardCut;
  64292. /** @hidden */
  64293. private onClipboardPaste;
  64294. /**
  64295. * Register the clipboard Events onto the canvas
  64296. */
  64297. registerClipboardEvents(): void;
  64298. /**
  64299. * Unregister the clipboard Events from the canvas
  64300. */
  64301. unRegisterClipboardEvents(): void;
  64302. /**
  64303. * Connect the texture to a hosting mesh to enable interactions
  64304. * @param mesh defines the mesh to attach to
  64305. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  64306. */
  64307. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  64308. /**
  64309. * Move the focus to a specific control
  64310. * @param control defines the control which will receive the focus
  64311. */
  64312. moveFocusToControl(control: IFocusableControl): void;
  64313. private _manageFocus;
  64314. private _attachToOnPointerOut;
  64315. /**
  64316. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  64317. * @param mesh defines the mesh which will receive the texture
  64318. * @param width defines the texture width (1024 by default)
  64319. * @param height defines the texture height (1024 by default)
  64320. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  64321. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  64322. * @returns a new AdvancedDynamicTexture
  64323. */
  64324. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  64325. /**
  64326. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  64327. * In this mode the texture will rely on a layer for its rendering.
  64328. * This allows it to be treated like any other layer.
  64329. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  64330. * LayerMask is set through advancedTexture.layer.layerMask
  64331. * @param name defines name for the texture
  64332. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  64333. * @param scene defines the hsoting scene
  64334. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  64335. * @returns a new AdvancedDynamicTexture
  64336. */
  64337. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  64338. }
  64339. }
  64340. declare module BABYLON.GUI {
  64341. /**
  64342. * Root class used for all 2D controls
  64343. * @see http://doc.babylonjs.com/how_to/gui#controls
  64344. */
  64345. export class Control {
  64346. /** defines the name of the control */
  64347. name?: string | undefined;
  64348. /**
  64349. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  64350. */
  64351. static AllowAlphaInheritance: boolean;
  64352. private _alpha;
  64353. private _alphaSet;
  64354. private _zIndex;
  64355. /** @hidden */
  64356. _host: AdvancedDynamicTexture;
  64357. /** Gets or sets the control parent */
  64358. parent: BABYLON.Nullable<Container>;
  64359. /** @hidden */
  64360. _currentMeasure: Measure;
  64361. private _fontFamily;
  64362. private _fontStyle;
  64363. private _fontWeight;
  64364. private _fontSize;
  64365. private _font;
  64366. /** @hidden */
  64367. _width: ValueAndUnit;
  64368. /** @hidden */
  64369. _height: ValueAndUnit;
  64370. /** @hidden */
  64371. protected _fontOffset: {
  64372. ascent: number;
  64373. height: number;
  64374. descent: number;
  64375. };
  64376. private _color;
  64377. private _style;
  64378. private _styleObserver;
  64379. /** @hidden */
  64380. protected _horizontalAlignment: number;
  64381. /** @hidden */
  64382. protected _verticalAlignment: number;
  64383. /** @hidden */
  64384. protected _isDirty: boolean;
  64385. /** @hidden */
  64386. protected _wasDirty: boolean;
  64387. /** @hidden */
  64388. _tempParentMeasure: Measure;
  64389. /** @hidden */
  64390. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  64391. /** @hidden */
  64392. protected _cachedParentMeasure: Measure;
  64393. private _paddingLeft;
  64394. private _paddingRight;
  64395. private _paddingTop;
  64396. private _paddingBottom;
  64397. /** @hidden */
  64398. _left: ValueAndUnit;
  64399. /** @hidden */
  64400. _top: ValueAndUnit;
  64401. private _scaleX;
  64402. private _scaleY;
  64403. private _rotation;
  64404. private _transformCenterX;
  64405. private _transformCenterY;
  64406. /** @hidden */
  64407. _transformMatrix: Matrix2D;
  64408. /** @hidden */
  64409. protected _invertTransformMatrix: Matrix2D;
  64410. /** @hidden */
  64411. protected _transformedPosition: BABYLON.Vector2;
  64412. private _isMatrixDirty;
  64413. private _cachedOffsetX;
  64414. private _cachedOffsetY;
  64415. private _isVisible;
  64416. private _isHighlighted;
  64417. /** @hidden */
  64418. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64419. private _fontSet;
  64420. private _dummyVector2;
  64421. private _downCount;
  64422. private _enterCount;
  64423. private _doNotRender;
  64424. private _downPointerIds;
  64425. protected _isEnabled: boolean;
  64426. protected _disabledColor: string;
  64427. /** @hidden */
  64428. protected _rebuildLayout: boolean;
  64429. /** @hidden */
  64430. _isClipped: boolean;
  64431. /** @hidden */
  64432. _tag: any;
  64433. /**
  64434. * 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
  64435. */
  64436. uniqueId: number;
  64437. /**
  64438. * Gets or sets an object used to store user defined information for the node
  64439. */
  64440. metadata: any;
  64441. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  64442. isHitTestVisible: boolean;
  64443. /** Gets or sets a boolean indicating if the control can block pointer events */
  64444. isPointerBlocker: boolean;
  64445. /** Gets or sets a boolean indicating if the control can be focusable */
  64446. isFocusInvisible: boolean;
  64447. /**
  64448. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  64449. * 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
  64450. */
  64451. clipChildren: boolean;
  64452. /**
  64453. * Gets or sets a boolean indicating that control content must be clipped
  64454. * 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
  64455. */
  64456. clipContent: boolean;
  64457. /**
  64458. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  64459. */
  64460. useBitmapCache: boolean;
  64461. private _cacheData;
  64462. private _shadowOffsetX;
  64463. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  64464. shadowOffsetX: number;
  64465. private _shadowOffsetY;
  64466. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  64467. shadowOffsetY: number;
  64468. private _shadowBlur;
  64469. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  64470. shadowBlur: number;
  64471. private _shadowColor;
  64472. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  64473. shadowColor: string;
  64474. /** Gets or sets the cursor to use when the control is hovered */
  64475. hoverCursor: string;
  64476. /** @hidden */
  64477. protected _linkOffsetX: ValueAndUnit;
  64478. /** @hidden */
  64479. protected _linkOffsetY: ValueAndUnit;
  64480. /** Gets the control type name */
  64481. readonly typeName: string;
  64482. /**
  64483. * Get the current class name of the control.
  64484. * @returns current class name
  64485. */
  64486. getClassName(): string;
  64487. /**
  64488. * An event triggered when the pointer move over the control.
  64489. */
  64490. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  64491. /**
  64492. * An event triggered when the pointer move out of the control.
  64493. */
  64494. onPointerOutObservable: BABYLON.Observable<Control>;
  64495. /**
  64496. * An event triggered when the pointer taps the control
  64497. */
  64498. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  64499. /**
  64500. * An event triggered when pointer up
  64501. */
  64502. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  64503. /**
  64504. * An event triggered when a control is clicked on
  64505. */
  64506. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  64507. /**
  64508. * An event triggered when pointer enters the control
  64509. */
  64510. onPointerEnterObservable: BABYLON.Observable<Control>;
  64511. /**
  64512. * An event triggered when the control is marked as dirty
  64513. */
  64514. onDirtyObservable: BABYLON.Observable<Control>;
  64515. /**
  64516. * An event triggered before drawing the control
  64517. */
  64518. onBeforeDrawObservable: BABYLON.Observable<Control>;
  64519. /**
  64520. * An event triggered after the control was drawn
  64521. */
  64522. onAfterDrawObservable: BABYLON.Observable<Control>;
  64523. /**
  64524. * Get the hosting AdvancedDynamicTexture
  64525. */
  64526. readonly host: AdvancedDynamicTexture;
  64527. /** Gets or set information about font offsets (used to render and align text) */
  64528. fontOffset: {
  64529. ascent: number;
  64530. height: number;
  64531. descent: number;
  64532. };
  64533. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  64534. alpha: number;
  64535. /**
  64536. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  64537. */
  64538. isHighlighted: boolean;
  64539. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  64540. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64541. */
  64542. scaleX: number;
  64543. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  64544. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64545. */
  64546. scaleY: number;
  64547. /** Gets or sets the rotation angle (0 by default)
  64548. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64549. */
  64550. rotation: number;
  64551. /** Gets or sets the transformation center on Y axis (0 by default)
  64552. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64553. */
  64554. transformCenterY: number;
  64555. /** Gets or sets the transformation center on X axis (0 by default)
  64556. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64557. */
  64558. transformCenterX: number;
  64559. /**
  64560. * Gets or sets the horizontal alignment
  64561. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64562. */
  64563. horizontalAlignment: number;
  64564. /**
  64565. * Gets or sets the vertical alignment
  64566. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64567. */
  64568. verticalAlignment: number;
  64569. /**
  64570. * Gets or sets control width
  64571. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64572. */
  64573. width: string | number;
  64574. /**
  64575. * Gets or sets the control width in pixel
  64576. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64577. */
  64578. widthInPixels: number;
  64579. /**
  64580. * Gets or sets control height
  64581. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64582. */
  64583. height: string | number;
  64584. /**
  64585. * Gets or sets control height in pixel
  64586. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64587. */
  64588. heightInPixels: number;
  64589. /** Gets or set font family */
  64590. fontFamily: string;
  64591. /** Gets or sets font style */
  64592. fontStyle: string;
  64593. /** Gets or sets font weight */
  64594. fontWeight: string;
  64595. /**
  64596. * Gets or sets style
  64597. * @see http://doc.babylonjs.com/how_to/gui#styles
  64598. */
  64599. style: BABYLON.Nullable<Style>;
  64600. /** @hidden */
  64601. readonly _isFontSizeInPercentage: boolean;
  64602. /** Gets or sets font size in pixels */
  64603. fontSizeInPixels: number;
  64604. /** Gets or sets font size */
  64605. fontSize: string | number;
  64606. /** Gets or sets foreground color */
  64607. color: string;
  64608. /** Gets or sets z index which is used to reorder controls on the z axis */
  64609. zIndex: number;
  64610. /** Gets or sets a boolean indicating if the control can be rendered */
  64611. notRenderable: boolean;
  64612. /** Gets or sets a boolean indicating if the control is visible */
  64613. isVisible: boolean;
  64614. /** Gets a boolean indicating that the control needs to update its rendering */
  64615. readonly isDirty: boolean;
  64616. /**
  64617. * Gets the current linked mesh (or null if none)
  64618. */
  64619. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64620. /**
  64621. * Gets or sets a value indicating the padding to use on the left of the control
  64622. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64623. */
  64624. paddingLeft: string | number;
  64625. /**
  64626. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  64627. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64628. */
  64629. paddingLeftInPixels: number;
  64630. /**
  64631. * Gets or sets a value indicating the padding to use on the right of the control
  64632. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64633. */
  64634. paddingRight: string | number;
  64635. /**
  64636. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  64637. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64638. */
  64639. paddingRightInPixels: number;
  64640. /**
  64641. * Gets or sets a value indicating the padding to use on the top of the control
  64642. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64643. */
  64644. paddingTop: string | number;
  64645. /**
  64646. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  64647. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64648. */
  64649. paddingTopInPixels: number;
  64650. /**
  64651. * Gets or sets a value indicating the padding to use on the bottom of the control
  64652. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64653. */
  64654. paddingBottom: string | number;
  64655. /**
  64656. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  64657. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64658. */
  64659. paddingBottomInPixels: number;
  64660. /**
  64661. * Gets or sets a value indicating the left coordinate of the control
  64662. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64663. */
  64664. left: string | number;
  64665. /**
  64666. * Gets or sets a value indicating the left coordinate in pixels of the control
  64667. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64668. */
  64669. leftInPixels: number;
  64670. /**
  64671. * Gets or sets a value indicating the top coordinate of the control
  64672. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64673. */
  64674. top: string | number;
  64675. /**
  64676. * Gets or sets a value indicating the top coordinate in pixels of the control
  64677. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64678. */
  64679. topInPixels: number;
  64680. /**
  64681. * Gets or sets a value indicating the offset on X axis to the linked mesh
  64682. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64683. */
  64684. linkOffsetX: string | number;
  64685. /**
  64686. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  64687. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64688. */
  64689. linkOffsetXInPixels: number;
  64690. /**
  64691. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  64692. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64693. */
  64694. linkOffsetY: string | number;
  64695. /**
  64696. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  64697. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64698. */
  64699. linkOffsetYInPixels: number;
  64700. /** Gets the center coordinate on X axis */
  64701. readonly centerX: number;
  64702. /** Gets the center coordinate on Y axis */
  64703. readonly centerY: number;
  64704. /** Gets or sets if control is Enabled*/
  64705. isEnabled: boolean;
  64706. /** Gets or sets background color of control if it's disabled*/
  64707. disabledColor: string;
  64708. /**
  64709. * Creates a new control
  64710. * @param name defines the name of the control
  64711. */
  64712. constructor(
  64713. /** defines the name of the control */
  64714. name?: string | undefined);
  64715. /** @hidden */
  64716. protected _getTypeName(): string;
  64717. /**
  64718. * Gets the first ascendant in the hierarchy of the given type
  64719. * @param className defines the required type
  64720. * @returns the ascendant or null if not found
  64721. */
  64722. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  64723. /** @hidden */
  64724. _resetFontCache(): void;
  64725. /**
  64726. * Determines if a container is an ascendant of the current control
  64727. * @param container defines the container to look for
  64728. * @returns true if the container is one of the ascendant of the control
  64729. */
  64730. isAscendant(container: Control): boolean;
  64731. /**
  64732. * Gets coordinates in local control space
  64733. * @param globalCoordinates defines the coordinates to transform
  64734. * @returns the new coordinates in local space
  64735. */
  64736. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64737. /**
  64738. * Gets coordinates in local control space
  64739. * @param globalCoordinates defines the coordinates to transform
  64740. * @param result defines the target vector2 where to store the result
  64741. * @returns the current control
  64742. */
  64743. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  64744. /**
  64745. * Gets coordinates in parent local control space
  64746. * @param globalCoordinates defines the coordinates to transform
  64747. * @returns the new coordinates in parent local space
  64748. */
  64749. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64750. /**
  64751. * Move the current control to a vector3 position projected onto the screen.
  64752. * @param position defines the target position
  64753. * @param scene defines the hosting scene
  64754. */
  64755. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  64756. /** @hidden */
  64757. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64758. /**
  64759. * Will return all controls that have this control as ascendant
  64760. * @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
  64761. * @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
  64762. * @return all child controls
  64763. */
  64764. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64765. /**
  64766. * Link current control with a target mesh
  64767. * @param mesh defines the mesh to link with
  64768. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64769. */
  64770. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  64771. /** @hidden */
  64772. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  64773. /** @hidden */
  64774. _offsetLeft(offset: number): void;
  64775. /** @hidden */
  64776. _offsetTop(offset: number): void;
  64777. /** @hidden */
  64778. _markMatrixAsDirty(): void;
  64779. /** @hidden */
  64780. _flagDescendantsAsMatrixDirty(): void;
  64781. /** @hidden */
  64782. _intersectsRect(rect: Measure): boolean;
  64783. /** @hidden */
  64784. protected invalidateRect(): void;
  64785. /** @hidden */
  64786. _markAsDirty(force?: boolean): void;
  64787. /** @hidden */
  64788. _markAllAsDirty(): void;
  64789. /** @hidden */
  64790. _link(host: AdvancedDynamicTexture): void;
  64791. /** @hidden */
  64792. protected _transform(context?: CanvasRenderingContext2D): void;
  64793. /** @hidden */
  64794. _renderHighlight(context: CanvasRenderingContext2D): void;
  64795. /** @hidden */
  64796. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64797. /** @hidden */
  64798. protected _applyStates(context: CanvasRenderingContext2D): void;
  64799. /** @hidden */
  64800. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64801. /** @hidden */
  64802. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64803. protected _evaluateClippingState(parentMeasure: Measure): void;
  64804. /** @hidden */
  64805. _measure(): void;
  64806. /** @hidden */
  64807. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64808. /** @hidden */
  64809. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64810. /** @hidden */
  64811. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64812. /** @hidden */
  64813. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64814. private static _ClipMeasure;
  64815. private _tmpMeasureA;
  64816. private _clip;
  64817. /** @hidden */
  64818. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  64819. /** @hidden */
  64820. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  64821. /**
  64822. * Tests if a given coordinates belong to the current control
  64823. * @param x defines x coordinate to test
  64824. * @param y defines y coordinate to test
  64825. * @returns true if the coordinates are inside the control
  64826. */
  64827. contains(x: number, y: number): boolean;
  64828. /** @hidden */
  64829. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64830. /** @hidden */
  64831. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64832. /** @hidden */
  64833. _onPointerEnter(target: Control): boolean;
  64834. /** @hidden */
  64835. _onPointerOut(target: Control, force?: boolean): void;
  64836. /** @hidden */
  64837. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64838. /** @hidden */
  64839. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64840. /** @hidden */
  64841. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  64842. /** @hidden */
  64843. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  64844. private _prepareFont;
  64845. /** Releases associated resources */
  64846. dispose(): void;
  64847. private static _HORIZONTAL_ALIGNMENT_LEFT;
  64848. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  64849. private static _HORIZONTAL_ALIGNMENT_CENTER;
  64850. private static _VERTICAL_ALIGNMENT_TOP;
  64851. private static _VERTICAL_ALIGNMENT_BOTTOM;
  64852. private static _VERTICAL_ALIGNMENT_CENTER;
  64853. /** HORIZONTAL_ALIGNMENT_LEFT */
  64854. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  64855. /** HORIZONTAL_ALIGNMENT_RIGHT */
  64856. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  64857. /** HORIZONTAL_ALIGNMENT_CENTER */
  64858. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  64859. /** VERTICAL_ALIGNMENT_TOP */
  64860. static readonly VERTICAL_ALIGNMENT_TOP: number;
  64861. /** VERTICAL_ALIGNMENT_BOTTOM */
  64862. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  64863. /** VERTICAL_ALIGNMENT_CENTER */
  64864. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  64865. private static _FontHeightSizes;
  64866. /** @hidden */
  64867. static _GetFontOffset(font: string): {
  64868. ascent: number;
  64869. height: number;
  64870. descent: number;
  64871. };
  64872. /**
  64873. * Creates a stack panel that can be used to render headers
  64874. * @param control defines the control to associate with the header
  64875. * @param text defines the text of the header
  64876. * @param size defines the size of the header
  64877. * @param options defines options used to configure the header
  64878. * @returns a new StackPanel
  64879. * @ignore
  64880. * @hidden
  64881. */
  64882. static AddHeader: (control: Control, text: string, size: string | number, options: {
  64883. isHorizontal: boolean;
  64884. controlFirst: boolean;
  64885. }) => any;
  64886. /** @hidden */
  64887. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  64888. }
  64889. }
  64890. declare module BABYLON.GUI {
  64891. /**
  64892. * Root class for 2D containers
  64893. * @see http://doc.babylonjs.com/how_to/gui#containers
  64894. */
  64895. export class Container extends Control {
  64896. name?: string | undefined;
  64897. /** @hidden */
  64898. protected _children: Control[];
  64899. /** @hidden */
  64900. protected _measureForChildren: Measure;
  64901. /** @hidden */
  64902. protected _background: string;
  64903. /** @hidden */
  64904. protected _adaptWidthToChildren: boolean;
  64905. /** @hidden */
  64906. protected _adaptHeightToChildren: boolean;
  64907. /**
  64908. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  64909. */
  64910. logLayoutCycleErrors: boolean;
  64911. /**
  64912. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  64913. */
  64914. maxLayoutCycle: number;
  64915. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  64916. adaptHeightToChildren: boolean;
  64917. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  64918. adaptWidthToChildren: boolean;
  64919. /** Gets or sets background color */
  64920. background: string;
  64921. /** Gets the list of children */
  64922. readonly children: Control[];
  64923. /**
  64924. * Creates a new Container
  64925. * @param name defines the name of the container
  64926. */
  64927. constructor(name?: string | undefined);
  64928. protected _getTypeName(): string;
  64929. _flagDescendantsAsMatrixDirty(): void;
  64930. /**
  64931. * Gets a child using its name
  64932. * @param name defines the child name to look for
  64933. * @returns the child control if found
  64934. */
  64935. getChildByName(name: string): BABYLON.Nullable<Control>;
  64936. /**
  64937. * Gets a child using its type and its name
  64938. * @param name defines the child name to look for
  64939. * @param type defines the child type to look for
  64940. * @returns the child control if found
  64941. */
  64942. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  64943. /**
  64944. * Search for a specific control in children
  64945. * @param control defines the control to look for
  64946. * @returns true if the control is in child list
  64947. */
  64948. containsControl(control: Control): boolean;
  64949. /**
  64950. * Adds a new control to the current container
  64951. * @param control defines the control to add
  64952. * @returns the current container
  64953. */
  64954. addControl(control: BABYLON.Nullable<Control>): Container;
  64955. /**
  64956. * Removes all controls from the current container
  64957. * @returns the current container
  64958. */
  64959. clearControls(): Container;
  64960. /**
  64961. * Removes a control from the current container
  64962. * @param control defines the control to remove
  64963. * @returns the current container
  64964. */
  64965. removeControl(control: Control): Container;
  64966. /** @hidden */
  64967. _reOrderControl(control: Control): void;
  64968. /** @hidden */
  64969. _offsetLeft(offset: number): void;
  64970. /** @hidden */
  64971. _offsetTop(offset: number): void;
  64972. /** @hidden */
  64973. _markAllAsDirty(): void;
  64974. /** @hidden */
  64975. protected _localDraw(context: CanvasRenderingContext2D): void;
  64976. /** @hidden */
  64977. _link(host: AdvancedDynamicTexture): void;
  64978. /** @hidden */
  64979. protected _beforeLayout(): void;
  64980. /** @hidden */
  64981. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64982. /** @hidden */
  64983. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64984. protected _postMeasure(): void;
  64985. /** @hidden */
  64986. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  64987. /** @hidden */
  64988. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64989. /** @hidden */
  64990. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64991. /** @hidden */
  64992. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64993. /** Releases associated resources */
  64994. dispose(): void;
  64995. }
  64996. }
  64997. declare module BABYLON.GUI {
  64998. /** Class used to create rectangle container */
  64999. export class Rectangle extends Container {
  65000. name?: string | undefined;
  65001. private _thickness;
  65002. private _cornerRadius;
  65003. /** Gets or sets border thickness */
  65004. thickness: number;
  65005. /** Gets or sets the corner radius angle */
  65006. cornerRadius: number;
  65007. /**
  65008. * Creates a new Rectangle
  65009. * @param name defines the control name
  65010. */
  65011. constructor(name?: string | undefined);
  65012. protected _getTypeName(): string;
  65013. protected _localDraw(context: CanvasRenderingContext2D): void;
  65014. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65015. private _drawRoundedRect;
  65016. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65017. }
  65018. }
  65019. declare module BABYLON.GUI {
  65020. /**
  65021. * Enum that determines the text-wrapping mode to use.
  65022. */
  65023. export enum TextWrapping {
  65024. /**
  65025. * Clip the text when it's larger than Control.width; this is the default mode.
  65026. */
  65027. Clip = 0,
  65028. /**
  65029. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  65030. */
  65031. WordWrap = 1,
  65032. /**
  65033. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  65034. */
  65035. Ellipsis = 2
  65036. }
  65037. /**
  65038. * Class used to create text block control
  65039. */
  65040. export class TextBlock extends Control {
  65041. /**
  65042. * Defines the name of the control
  65043. */
  65044. name?: string | undefined;
  65045. private _text;
  65046. private _textWrapping;
  65047. private _textHorizontalAlignment;
  65048. private _textVerticalAlignment;
  65049. private _lines;
  65050. private _resizeToFit;
  65051. private _lineSpacing;
  65052. private _outlineWidth;
  65053. private _outlineColor;
  65054. /**
  65055. * An event triggered after the text is changed
  65056. */
  65057. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  65058. /**
  65059. * An event triggered after the text was broken up into lines
  65060. */
  65061. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  65062. /**
  65063. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  65064. */
  65065. readonly lines: any[];
  65066. /**
  65067. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  65068. */
  65069. /**
  65070. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  65071. */
  65072. resizeToFit: boolean;
  65073. /**
  65074. * Gets or sets a boolean indicating if text must be wrapped
  65075. */
  65076. /**
  65077. * Gets or sets a boolean indicating if text must be wrapped
  65078. */
  65079. textWrapping: TextWrapping | boolean;
  65080. /**
  65081. * Gets or sets text to display
  65082. */
  65083. /**
  65084. * Gets or sets text to display
  65085. */
  65086. text: string;
  65087. /**
  65088. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  65089. */
  65090. /**
  65091. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  65092. */
  65093. textHorizontalAlignment: number;
  65094. /**
  65095. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  65096. */
  65097. /**
  65098. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  65099. */
  65100. textVerticalAlignment: number;
  65101. /**
  65102. * Gets or sets line spacing value
  65103. */
  65104. /**
  65105. * Gets or sets line spacing value
  65106. */
  65107. lineSpacing: string | number;
  65108. /**
  65109. * Gets or sets outlineWidth of the text to display
  65110. */
  65111. /**
  65112. * Gets or sets outlineWidth of the text to display
  65113. */
  65114. outlineWidth: number;
  65115. /**
  65116. * Gets or sets outlineColor of the text to display
  65117. */
  65118. /**
  65119. * Gets or sets outlineColor of the text to display
  65120. */
  65121. outlineColor: string;
  65122. /**
  65123. * Creates a new TextBlock object
  65124. * @param name defines the name of the control
  65125. * @param text defines the text to display (emptry string by default)
  65126. */
  65127. constructor(
  65128. /**
  65129. * Defines the name of the control
  65130. */
  65131. name?: string | undefined, text?: string);
  65132. protected _getTypeName(): string;
  65133. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65134. private _drawText;
  65135. /** @hidden */
  65136. _draw(context: CanvasRenderingContext2D): void;
  65137. protected _applyStates(context: CanvasRenderingContext2D): void;
  65138. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  65139. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  65140. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  65141. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  65142. protected _renderLines(context: CanvasRenderingContext2D): void;
  65143. /**
  65144. * Given a width constraint applied on the text block, find the expected height
  65145. * @returns expected height
  65146. */
  65147. computeExpectedHeight(): number;
  65148. dispose(): void;
  65149. }
  65150. }
  65151. declare module BABYLON.GUI {
  65152. /**
  65153. * Class used to create 2D images
  65154. */
  65155. export class Image extends Control {
  65156. name?: string | undefined;
  65157. private static _WorkingCanvas;
  65158. private _domImage;
  65159. private _imageWidth;
  65160. private _imageHeight;
  65161. private _loaded;
  65162. private _stretch;
  65163. private _source;
  65164. private _autoScale;
  65165. private _sourceLeft;
  65166. private _sourceTop;
  65167. private _sourceWidth;
  65168. private _sourceHeight;
  65169. private _cellWidth;
  65170. private _cellHeight;
  65171. private _cellId;
  65172. private _populateNinePatchSlicesFromImage;
  65173. private _sliceLeft;
  65174. private _sliceRight;
  65175. private _sliceTop;
  65176. private _sliceBottom;
  65177. private _detectPointerOnOpaqueOnly;
  65178. /**
  65179. * BABYLON.Observable notified when the content is loaded
  65180. */
  65181. onImageLoadedObservable: BABYLON.Observable<Image>;
  65182. /**
  65183. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  65184. */
  65185. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  65186. /**
  65187. * Gets a boolean indicating that the content is loaded
  65188. */
  65189. readonly isLoaded: boolean;
  65190. /**
  65191. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  65192. */
  65193. populateNinePatchSlicesFromImage: boolean;
  65194. /**
  65195. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  65196. * Beware using this as this will comsume more memory as the image has to be stored twice
  65197. */
  65198. detectPointerOnOpaqueOnly: boolean;
  65199. /**
  65200. * Gets or sets the left value for slicing (9-patch)
  65201. */
  65202. sliceLeft: number;
  65203. /**
  65204. * Gets or sets the right value for slicing (9-patch)
  65205. */
  65206. sliceRight: number;
  65207. /**
  65208. * Gets or sets the top value for slicing (9-patch)
  65209. */
  65210. sliceTop: number;
  65211. /**
  65212. * Gets or sets the bottom value for slicing (9-patch)
  65213. */
  65214. sliceBottom: number;
  65215. /**
  65216. * Gets or sets the left coordinate in the source image
  65217. */
  65218. sourceLeft: number;
  65219. /**
  65220. * Gets or sets the top coordinate in the source image
  65221. */
  65222. sourceTop: number;
  65223. /**
  65224. * Gets or sets the width to capture in the source image
  65225. */
  65226. sourceWidth: number;
  65227. /**
  65228. * Gets or sets the height to capture in the source image
  65229. */
  65230. sourceHeight: number;
  65231. /**
  65232. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  65233. * @see http://doc.babylonjs.com/how_to/gui#image
  65234. */
  65235. autoScale: boolean;
  65236. /** Gets or sets the streching mode used by the image */
  65237. stretch: number;
  65238. /**
  65239. * Gets or sets the internal DOM image used to render the control
  65240. */
  65241. domImage: HTMLImageElement;
  65242. private _onImageLoaded;
  65243. private _extractNinePatchSliceDataFromImage;
  65244. /**
  65245. * Gets or sets image source url
  65246. */
  65247. source: BABYLON.Nullable<string>;
  65248. /**
  65249. * Checks for svg document with icon id present
  65250. */
  65251. private _svgCheck;
  65252. /**
  65253. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  65254. * given external svg file and icon id
  65255. */
  65256. private _getSVGAttribs;
  65257. /**
  65258. * Gets or sets the cell width to use when animation sheet is enabled
  65259. * @see http://doc.babylonjs.com/how_to/gui#image
  65260. */
  65261. cellWidth: number;
  65262. /**
  65263. * Gets or sets the cell height to use when animation sheet is enabled
  65264. * @see http://doc.babylonjs.com/how_to/gui#image
  65265. */
  65266. cellHeight: number;
  65267. /**
  65268. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  65269. * @see http://doc.babylonjs.com/how_to/gui#image
  65270. */
  65271. cellId: number;
  65272. /**
  65273. * Creates a new Image
  65274. * @param name defines the control name
  65275. * @param url defines the image url
  65276. */
  65277. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  65278. /**
  65279. * Tests if a given coordinates belong to the current control
  65280. * @param x defines x coordinate to test
  65281. * @param y defines y coordinate to test
  65282. * @returns true if the coordinates are inside the control
  65283. */
  65284. contains(x: number, y: number): boolean;
  65285. protected _getTypeName(): string;
  65286. /** Force the control to synchronize with its content */
  65287. synchronizeSizeWithContent(): void;
  65288. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65289. private _prepareWorkingCanvasForOpaqueDetection;
  65290. private _drawImage;
  65291. _draw(context: CanvasRenderingContext2D): void;
  65292. private _renderCornerPatch;
  65293. private _renderNinePatch;
  65294. dispose(): void;
  65295. /** STRETCH_NONE */
  65296. static readonly STRETCH_NONE: number;
  65297. /** STRETCH_FILL */
  65298. static readonly STRETCH_FILL: number;
  65299. /** STRETCH_UNIFORM */
  65300. static readonly STRETCH_UNIFORM: number;
  65301. /** STRETCH_EXTEND */
  65302. static readonly STRETCH_EXTEND: number;
  65303. /** NINE_PATCH */
  65304. static readonly STRETCH_NINE_PATCH: number;
  65305. }
  65306. }
  65307. declare module BABYLON.GUI {
  65308. /**
  65309. * Class used to create 2D buttons
  65310. */
  65311. export class Button extends Rectangle {
  65312. name?: string | undefined;
  65313. /**
  65314. * Function called to generate a pointer enter animation
  65315. */
  65316. pointerEnterAnimation: () => void;
  65317. /**
  65318. * Function called to generate a pointer out animation
  65319. */
  65320. pointerOutAnimation: () => void;
  65321. /**
  65322. * Function called to generate a pointer down animation
  65323. */
  65324. pointerDownAnimation: () => void;
  65325. /**
  65326. * Function called to generate a pointer up animation
  65327. */
  65328. pointerUpAnimation: () => void;
  65329. /**
  65330. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  65331. */
  65332. delegatePickingToChildren: boolean;
  65333. private _image;
  65334. /**
  65335. * Returns the image part of the button (if any)
  65336. */
  65337. readonly image: BABYLON.Nullable<Image>;
  65338. private _textBlock;
  65339. /**
  65340. * Returns the image part of the button (if any)
  65341. */
  65342. readonly textBlock: BABYLON.Nullable<TextBlock>;
  65343. /**
  65344. * Creates a new Button
  65345. * @param name defines the name of the button
  65346. */
  65347. constructor(name?: string | undefined);
  65348. protected _getTypeName(): string;
  65349. /** @hidden */
  65350. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65351. /** @hidden */
  65352. _onPointerEnter(target: Control): boolean;
  65353. /** @hidden */
  65354. _onPointerOut(target: Control, force?: boolean): void;
  65355. /** @hidden */
  65356. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65357. /** @hidden */
  65358. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65359. /**
  65360. * Creates a new button made with an image and a text
  65361. * @param name defines the name of the button
  65362. * @param text defines the text of the button
  65363. * @param imageUrl defines the url of the image
  65364. * @returns a new Button
  65365. */
  65366. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  65367. /**
  65368. * Creates a new button made with an image
  65369. * @param name defines the name of the button
  65370. * @param imageUrl defines the url of the image
  65371. * @returns a new Button
  65372. */
  65373. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  65374. /**
  65375. * Creates a new button made with a text
  65376. * @param name defines the name of the button
  65377. * @param text defines the text of the button
  65378. * @returns a new Button
  65379. */
  65380. static CreateSimpleButton(name: string, text: string): Button;
  65381. /**
  65382. * Creates a new button made with an image and a centered text
  65383. * @param name defines the name of the button
  65384. * @param text defines the text of the button
  65385. * @param imageUrl defines the url of the image
  65386. * @returns a new Button
  65387. */
  65388. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  65389. }
  65390. }
  65391. declare module BABYLON.GUI {
  65392. /**
  65393. * Class used to create a 2D stack panel container
  65394. */
  65395. export class StackPanel extends Container {
  65396. name?: string | undefined;
  65397. private _isVertical;
  65398. private _manualWidth;
  65399. private _manualHeight;
  65400. private _doNotTrackManualChanges;
  65401. /**
  65402. * Gets or sets a boolean indicating that layou warnings should be ignored
  65403. */
  65404. ignoreLayoutWarnings: boolean;
  65405. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  65406. isVertical: boolean;
  65407. /**
  65408. * Gets or sets panel width.
  65409. * This value should not be set when in horizontal mode as it will be computed automatically
  65410. */
  65411. width: string | number;
  65412. /**
  65413. * Gets or sets panel height.
  65414. * This value should not be set when in vertical mode as it will be computed automatically
  65415. */
  65416. height: string | number;
  65417. /**
  65418. * Creates a new StackPanel
  65419. * @param name defines control name
  65420. */
  65421. constructor(name?: string | undefined);
  65422. protected _getTypeName(): string;
  65423. /** @hidden */
  65424. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65425. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65426. protected _postMeasure(): void;
  65427. }
  65428. }
  65429. declare module BABYLON.GUI {
  65430. /**
  65431. * Class used to represent a 2D checkbox
  65432. */
  65433. export class Checkbox extends Control {
  65434. name?: string | undefined;
  65435. private _isChecked;
  65436. private _background;
  65437. private _checkSizeRatio;
  65438. private _thickness;
  65439. /** Gets or sets border thickness */
  65440. thickness: number;
  65441. /**
  65442. * BABYLON.Observable raised when isChecked property changes
  65443. */
  65444. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65445. /** Gets or sets a value indicating the ratio between overall size and check size */
  65446. checkSizeRatio: number;
  65447. /** Gets or sets background color */
  65448. background: string;
  65449. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65450. isChecked: boolean;
  65451. /**
  65452. * Creates a new CheckBox
  65453. * @param name defines the control name
  65454. */
  65455. constructor(name?: string | undefined);
  65456. protected _getTypeName(): string;
  65457. /** @hidden */
  65458. _draw(context: CanvasRenderingContext2D): void;
  65459. /** @hidden */
  65460. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65461. /**
  65462. * Utility function to easily create a checkbox with a header
  65463. * @param title defines the label to use for the header
  65464. * @param onValueChanged defines the callback to call when value changes
  65465. * @returns a StackPanel containing the checkbox and a textBlock
  65466. */
  65467. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  65468. }
  65469. }
  65470. declare module BABYLON.GUI {
  65471. /**
  65472. * Class used to store key control properties
  65473. */
  65474. export class KeyPropertySet {
  65475. /** Width */
  65476. width?: string;
  65477. /** Height */
  65478. height?: string;
  65479. /** Left padding */
  65480. paddingLeft?: string;
  65481. /** Right padding */
  65482. paddingRight?: string;
  65483. /** Top padding */
  65484. paddingTop?: string;
  65485. /** Bottom padding */
  65486. paddingBottom?: string;
  65487. /** Foreground color */
  65488. color?: string;
  65489. /** Background color */
  65490. background?: string;
  65491. }
  65492. /**
  65493. * Class used to create virtual keyboard
  65494. */
  65495. export class VirtualKeyboard extends StackPanel {
  65496. /** BABYLON.Observable raised when a key is pressed */
  65497. onKeyPressObservable: BABYLON.Observable<string>;
  65498. /** Gets or sets default key button width */
  65499. defaultButtonWidth: string;
  65500. /** Gets or sets default key button height */
  65501. defaultButtonHeight: string;
  65502. /** Gets or sets default key button left padding */
  65503. defaultButtonPaddingLeft: string;
  65504. /** Gets or sets default key button right padding */
  65505. defaultButtonPaddingRight: string;
  65506. /** Gets or sets default key button top padding */
  65507. defaultButtonPaddingTop: string;
  65508. /** Gets or sets default key button bottom padding */
  65509. defaultButtonPaddingBottom: string;
  65510. /** Gets or sets default key button foreground color */
  65511. defaultButtonColor: string;
  65512. /** Gets or sets default key button background color */
  65513. defaultButtonBackground: string;
  65514. /** Gets or sets shift button foreground color */
  65515. shiftButtonColor: string;
  65516. /** Gets or sets shift button thickness*/
  65517. selectedShiftThickness: number;
  65518. /** Gets shift key state */
  65519. shiftState: number;
  65520. protected _getTypeName(): string;
  65521. private _createKey;
  65522. /**
  65523. * Adds a new row of keys
  65524. * @param keys defines the list of keys to add
  65525. * @param propertySets defines the associated property sets
  65526. */
  65527. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  65528. /**
  65529. * Set the shift key to a specific state
  65530. * @param shiftState defines the new shift state
  65531. */
  65532. applyShiftState(shiftState: number): void;
  65533. private _currentlyConnectedInputText;
  65534. private _connectedInputTexts;
  65535. private _onKeyPressObserver;
  65536. /** Gets the input text control currently attached to the keyboard */
  65537. readonly connectedInputText: BABYLON.Nullable<InputText>;
  65538. /**
  65539. * Connects the keyboard with an input text control
  65540. *
  65541. * @param input defines the target control
  65542. */
  65543. connect(input: InputText): void;
  65544. /**
  65545. * Disconnects the keyboard from connected InputText controls
  65546. *
  65547. * @param input optionally defines a target control, otherwise all are disconnected
  65548. */
  65549. disconnect(input?: InputText): void;
  65550. private _removeConnectedInputObservables;
  65551. /**
  65552. * Release all resources
  65553. */
  65554. dispose(): void;
  65555. /**
  65556. * Creates a new keyboard using a default layout
  65557. *
  65558. * @param name defines control name
  65559. * @returns a new VirtualKeyboard
  65560. */
  65561. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  65562. }
  65563. }
  65564. declare module BABYLON.GUI {
  65565. /**
  65566. * Class used to create input text control
  65567. */
  65568. export class InputText extends Control implements IFocusableControl {
  65569. name?: string | undefined;
  65570. private _text;
  65571. private _placeholderText;
  65572. private _background;
  65573. private _focusedBackground;
  65574. private _focusedColor;
  65575. private _placeholderColor;
  65576. private _thickness;
  65577. private _margin;
  65578. private _autoStretchWidth;
  65579. private _maxWidth;
  65580. private _isFocused;
  65581. private _blinkTimeout;
  65582. private _blinkIsEven;
  65583. private _cursorOffset;
  65584. private _scrollLeft;
  65585. private _textWidth;
  65586. private _clickedCoordinate;
  65587. private _deadKey;
  65588. private _addKey;
  65589. private _currentKey;
  65590. private _isTextHighlightOn;
  65591. private _textHighlightColor;
  65592. private _highligherOpacity;
  65593. private _highlightedText;
  65594. private _startHighlightIndex;
  65595. private _endHighlightIndex;
  65596. private _cursorIndex;
  65597. private _onFocusSelectAll;
  65598. private _isPointerDown;
  65599. private _onClipboardObserver;
  65600. private _onPointerDblTapObserver;
  65601. /** @hidden */
  65602. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  65603. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  65604. promptMessage: string;
  65605. /** Force disable prompt on mobile device */
  65606. disableMobilePrompt: boolean;
  65607. /** BABYLON.Observable raised when the text changes */
  65608. onTextChangedObservable: BABYLON.Observable<InputText>;
  65609. /** BABYLON.Observable raised just before an entered character is to be added */
  65610. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  65611. /** BABYLON.Observable raised when the control gets the focus */
  65612. onFocusObservable: BABYLON.Observable<InputText>;
  65613. /** BABYLON.Observable raised when the control loses the focus */
  65614. onBlurObservable: BABYLON.Observable<InputText>;
  65615. /**Observable raised when the text is highlighted */
  65616. onTextHighlightObservable: BABYLON.Observable<InputText>;
  65617. /**Observable raised when copy event is triggered */
  65618. onTextCopyObservable: BABYLON.Observable<InputText>;
  65619. /** BABYLON.Observable raised when cut event is triggered */
  65620. onTextCutObservable: BABYLON.Observable<InputText>;
  65621. /** BABYLON.Observable raised when paste event is triggered */
  65622. onTextPasteObservable: BABYLON.Observable<InputText>;
  65623. /** BABYLON.Observable raised when a key event was processed */
  65624. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  65625. /** Gets or sets the maximum width allowed by the control */
  65626. maxWidth: string | number;
  65627. /** Gets the maximum width allowed by the control in pixels */
  65628. readonly maxWidthInPixels: number;
  65629. /** Gets or sets the text highlighter transparency; default: 0.4 */
  65630. highligherOpacity: number;
  65631. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  65632. onFocusSelectAll: boolean;
  65633. /** Gets or sets the text hightlight color */
  65634. textHighlightColor: string;
  65635. /** Gets or sets control margin */
  65636. margin: string;
  65637. /** Gets control margin in pixels */
  65638. readonly marginInPixels: number;
  65639. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  65640. autoStretchWidth: boolean;
  65641. /** Gets or sets border thickness */
  65642. thickness: number;
  65643. /** Gets or sets the background color when focused */
  65644. focusedBackground: string;
  65645. /** Gets or sets the background color when focused */
  65646. focusedColor: string;
  65647. /** Gets or sets the background color */
  65648. background: string;
  65649. /** Gets or sets the placeholder color */
  65650. placeholderColor: string;
  65651. /** Gets or sets the text displayed when the control is empty */
  65652. placeholderText: string;
  65653. /** Gets or sets the dead key flag */
  65654. deadKey: boolean;
  65655. /** Gets or sets the highlight text */
  65656. highlightedText: string;
  65657. /** Gets or sets if the current key should be added */
  65658. addKey: boolean;
  65659. /** Gets or sets the value of the current key being entered */
  65660. currentKey: string;
  65661. /** Gets or sets the text displayed in the control */
  65662. text: string;
  65663. /** Gets or sets control width */
  65664. width: string | number;
  65665. /**
  65666. * Creates a new InputText
  65667. * @param name defines the control name
  65668. * @param text defines the text of the control
  65669. */
  65670. constructor(name?: string | undefined, text?: string);
  65671. /** @hidden */
  65672. onBlur(): void;
  65673. /** @hidden */
  65674. onFocus(): void;
  65675. protected _getTypeName(): string;
  65676. /**
  65677. * Function called to get the list of controls that should not steal the focus from this control
  65678. * @returns an array of controls
  65679. */
  65680. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  65681. /** @hidden */
  65682. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  65683. /** @hidden */
  65684. private _updateValueFromCursorIndex;
  65685. /** @hidden */
  65686. private _processDblClick;
  65687. /** @hidden */
  65688. private _selectAllText;
  65689. /**
  65690. * Handles the keyboard event
  65691. * @param evt Defines the KeyboardEvent
  65692. */
  65693. processKeyboard(evt: KeyboardEvent): void;
  65694. /** @hidden */
  65695. private _onCopyText;
  65696. /** @hidden */
  65697. private _onCutText;
  65698. /** @hidden */
  65699. private _onPasteText;
  65700. _draw(context: CanvasRenderingContext2D): void;
  65701. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65702. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65703. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65704. protected _beforeRenderText(text: string): string;
  65705. dispose(): void;
  65706. }
  65707. }
  65708. declare module BABYLON.GUI {
  65709. /**
  65710. * Class used to create a 2D grid container
  65711. */
  65712. export class Grid extends Container {
  65713. name?: string | undefined;
  65714. private _rowDefinitions;
  65715. private _columnDefinitions;
  65716. private _cells;
  65717. private _childControls;
  65718. /**
  65719. * Gets the number of columns
  65720. */
  65721. readonly columnCount: number;
  65722. /**
  65723. * Gets the number of rows
  65724. */
  65725. readonly rowCount: number;
  65726. /** Gets the list of children */
  65727. readonly children: Control[];
  65728. /** Gets the list of cells (e.g. the containers) */
  65729. readonly cells: {
  65730. [key: string]: Container;
  65731. };
  65732. /**
  65733. * Gets the definition of a specific row
  65734. * @param index defines the index of the row
  65735. * @returns the row definition
  65736. */
  65737. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65738. /**
  65739. * Gets the definition of a specific column
  65740. * @param index defines the index of the column
  65741. * @returns the column definition
  65742. */
  65743. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65744. /**
  65745. * Adds a new row to the grid
  65746. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65747. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  65748. * @returns the current grid
  65749. */
  65750. addRowDefinition(height: number, isPixel?: boolean): Grid;
  65751. /**
  65752. * Adds a new column to the grid
  65753. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65754. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65755. * @returns the current grid
  65756. */
  65757. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  65758. /**
  65759. * Update a row definition
  65760. * @param index defines the index of the row to update
  65761. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65762. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  65763. * @returns the current grid
  65764. */
  65765. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  65766. /**
  65767. * Update a column definition
  65768. * @param index defines the index of the column to update
  65769. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65770. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65771. * @returns the current grid
  65772. */
  65773. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  65774. /**
  65775. * Gets the list of children stored in a specific cell
  65776. * @param row defines the row to check
  65777. * @param column defines the column to check
  65778. * @returns the list of controls
  65779. */
  65780. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  65781. /**
  65782. * Gets a string representing the child cell info (row x column)
  65783. * @param child defines the control to get info from
  65784. * @returns a string containing the child cell info (row x column)
  65785. */
  65786. getChildCellInfo(child: Control): string;
  65787. private _removeCell;
  65788. private _offsetCell;
  65789. /**
  65790. * Remove a column definition at specified index
  65791. * @param index defines the index of the column to remove
  65792. * @returns the current grid
  65793. */
  65794. removeColumnDefinition(index: number): Grid;
  65795. /**
  65796. * Remove a row definition at specified index
  65797. * @param index defines the index of the row to remove
  65798. * @returns the current grid
  65799. */
  65800. removeRowDefinition(index: number): Grid;
  65801. /**
  65802. * Adds a new control to the current grid
  65803. * @param control defines the control to add
  65804. * @param row defines the row where to add the control (0 by default)
  65805. * @param column defines the column where to add the control (0 by default)
  65806. * @returns the current grid
  65807. */
  65808. addControl(control: Control, row?: number, column?: number): Grid;
  65809. /**
  65810. * Removes a control from the current container
  65811. * @param control defines the control to remove
  65812. * @returns the current container
  65813. */
  65814. removeControl(control: Control): Container;
  65815. /**
  65816. * Creates a new Grid
  65817. * @param name defines control name
  65818. */
  65819. constructor(name?: string | undefined);
  65820. protected _getTypeName(): string;
  65821. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  65822. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65823. _flagDescendantsAsMatrixDirty(): void;
  65824. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65825. /** Releases associated resources */
  65826. dispose(): void;
  65827. }
  65828. }
  65829. declare module BABYLON.GUI {
  65830. /** Class used to create color pickers */
  65831. export class ColorPicker extends Control {
  65832. name?: string | undefined;
  65833. private static _Epsilon;
  65834. private _colorWheelCanvas;
  65835. private _value;
  65836. private _tmpColor;
  65837. private _pointerStartedOnSquare;
  65838. private _pointerStartedOnWheel;
  65839. private _squareLeft;
  65840. private _squareTop;
  65841. private _squareSize;
  65842. private _h;
  65843. private _s;
  65844. private _v;
  65845. private _lastPointerDownID;
  65846. /**
  65847. * BABYLON.Observable raised when the value changes
  65848. */
  65849. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  65850. /** Gets or sets the color of the color picker */
  65851. value: BABYLON.Color3;
  65852. /**
  65853. * Gets or sets control width
  65854. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65855. */
  65856. width: string | number;
  65857. /**
  65858. * Gets or sets control height
  65859. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65860. */
  65861. /** Gets or sets control height */
  65862. height: string | number;
  65863. /** Gets or sets control size */
  65864. size: string | number;
  65865. /**
  65866. * Creates a new ColorPicker
  65867. * @param name defines the control name
  65868. */
  65869. constructor(name?: string | undefined);
  65870. protected _getTypeName(): string;
  65871. /** @hidden */
  65872. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65873. private _updateSquareProps;
  65874. private _drawGradientSquare;
  65875. private _drawCircle;
  65876. private _createColorWheelCanvas;
  65877. /** @hidden */
  65878. _draw(context: CanvasRenderingContext2D): void;
  65879. private _pointerIsDown;
  65880. private _updateValueFromPointer;
  65881. private _isPointOnSquare;
  65882. private _isPointOnWheel;
  65883. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65884. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65885. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65886. /**
  65887. * This function expands the color picker by creating a color picker dialog with manual
  65888. * color value input and the ability to save colors into an array to be used later in
  65889. * subsequent launches of the dialogue.
  65890. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  65891. * @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.
  65892. * @returns picked color as a hex string and the saved colors array as hex strings.
  65893. */
  65894. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  65895. pickerWidth?: string;
  65896. pickerHeight?: string;
  65897. headerHeight?: string;
  65898. lastColor?: string;
  65899. swatchLimit?: number;
  65900. numSwatchesPerLine?: number;
  65901. savedColors?: Array<string>;
  65902. }): Promise<{
  65903. savedColors?: string[];
  65904. pickedColor: string;
  65905. }>;
  65906. }
  65907. }
  65908. declare module BABYLON.GUI {
  65909. /** Class used to create 2D ellipse containers */
  65910. export class Ellipse extends Container {
  65911. name?: string | undefined;
  65912. private _thickness;
  65913. /** Gets or sets border thickness */
  65914. thickness: number;
  65915. /**
  65916. * Creates a new Ellipse
  65917. * @param name defines the control name
  65918. */
  65919. constructor(name?: string | undefined);
  65920. protected _getTypeName(): string;
  65921. protected _localDraw(context: CanvasRenderingContext2D): void;
  65922. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65923. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65924. }
  65925. }
  65926. declare module BABYLON.GUI {
  65927. /**
  65928. * Class used to create a password control
  65929. */
  65930. export class InputPassword extends InputText {
  65931. protected _beforeRenderText(text: string): string;
  65932. }
  65933. }
  65934. declare module BABYLON.GUI {
  65935. /** Class used to render 2D lines */
  65936. export class Line extends Control {
  65937. name?: string | undefined;
  65938. private _lineWidth;
  65939. private _x1;
  65940. private _y1;
  65941. private _x2;
  65942. private _y2;
  65943. private _dash;
  65944. private _connectedControl;
  65945. private _connectedControlDirtyObserver;
  65946. /** Gets or sets the dash pattern */
  65947. dash: Array<number>;
  65948. /** Gets or sets the control connected with the line end */
  65949. connectedControl: Control;
  65950. /** Gets or sets start coordinates on X axis */
  65951. x1: string | number;
  65952. /** Gets or sets start coordinates on Y axis */
  65953. y1: string | number;
  65954. /** Gets or sets end coordinates on X axis */
  65955. x2: string | number;
  65956. /** Gets or sets end coordinates on Y axis */
  65957. y2: string | number;
  65958. /** Gets or sets line width */
  65959. lineWidth: number;
  65960. /** Gets or sets horizontal alignment */
  65961. horizontalAlignment: number;
  65962. /** Gets or sets vertical alignment */
  65963. verticalAlignment: number;
  65964. private readonly _effectiveX2;
  65965. private readonly _effectiveY2;
  65966. /**
  65967. * Creates a new Line
  65968. * @param name defines the control name
  65969. */
  65970. constructor(name?: string | undefined);
  65971. protected _getTypeName(): string;
  65972. _draw(context: CanvasRenderingContext2D): void;
  65973. _measure(): void;
  65974. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65975. /**
  65976. * Move one end of the line given 3D cartesian coordinates.
  65977. * @param position Targeted world position
  65978. * @param scene BABYLON.Scene
  65979. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65980. */
  65981. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  65982. /**
  65983. * Move one end of the line to a position in screen absolute space.
  65984. * @param projectedPosition Position in screen absolute space (X, Y)
  65985. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65986. */
  65987. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  65988. }
  65989. }
  65990. declare module BABYLON.GUI {
  65991. /**
  65992. * Class used to store a point for a MultiLine object.
  65993. * The point can be pure 2D coordinates, a mesh or a control
  65994. */
  65995. export class MultiLinePoint {
  65996. private _multiLine;
  65997. private _x;
  65998. private _y;
  65999. private _control;
  66000. private _mesh;
  66001. private _controlObserver;
  66002. private _meshObserver;
  66003. /** @hidden */
  66004. _point: BABYLON.Vector2;
  66005. /**
  66006. * Creates a new MultiLinePoint
  66007. * @param multiLine defines the source MultiLine object
  66008. */
  66009. constructor(multiLine: MultiLine);
  66010. /** Gets or sets x coordinate */
  66011. x: string | number;
  66012. /** Gets or sets y coordinate */
  66013. y: string | number;
  66014. /** Gets or sets the control associated with this point */
  66015. control: BABYLON.Nullable<Control>;
  66016. /** Gets or sets the mesh associated with this point */
  66017. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66018. /** Resets links */
  66019. resetLinks(): void;
  66020. /**
  66021. * Gets a translation vector
  66022. * @returns the translation vector
  66023. */
  66024. translate(): BABYLON.Vector2;
  66025. private _translatePoint;
  66026. /** Release associated resources */
  66027. dispose(): void;
  66028. }
  66029. }
  66030. declare module BABYLON.GUI {
  66031. /**
  66032. * Class used to create multi line control
  66033. */
  66034. export class MultiLine extends Control {
  66035. name?: string | undefined;
  66036. private _lineWidth;
  66037. private _dash;
  66038. private _points;
  66039. private _minX;
  66040. private _minY;
  66041. private _maxX;
  66042. private _maxY;
  66043. /**
  66044. * Creates a new MultiLine
  66045. * @param name defines the control name
  66046. */
  66047. constructor(name?: string | undefined);
  66048. /** Gets or sets dash pattern */
  66049. dash: Array<number>;
  66050. /**
  66051. * Gets point stored at specified index
  66052. * @param index defines the index to look for
  66053. * @returns the requested point if found
  66054. */
  66055. getAt(index: number): MultiLinePoint;
  66056. /** Function called when a point is updated */
  66057. onPointUpdate: () => void;
  66058. /**
  66059. * Adds new points to the point collection
  66060. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  66061. * @returns the list of created MultiLinePoint
  66062. */
  66063. add(...items: (AbstractMesh | Control | {
  66064. x: string | number;
  66065. y: string | number;
  66066. })[]): MultiLinePoint[];
  66067. /**
  66068. * Adds a new point to the point collection
  66069. * @param item defines the item (mesh, control or 2d coordiantes) to add
  66070. * @returns the created MultiLinePoint
  66071. */
  66072. push(item?: (AbstractMesh | Control | {
  66073. x: string | number;
  66074. y: string | number;
  66075. })): MultiLinePoint;
  66076. /**
  66077. * Remove a specific value or point from the active point collection
  66078. * @param value defines the value or point to remove
  66079. */
  66080. remove(value: number | MultiLinePoint): void;
  66081. /**
  66082. * Resets this object to initial state (no point)
  66083. */
  66084. reset(): void;
  66085. /**
  66086. * Resets all links
  66087. */
  66088. resetLinks(): void;
  66089. /** Gets or sets line width */
  66090. lineWidth: number;
  66091. horizontalAlignment: number;
  66092. verticalAlignment: number;
  66093. protected _getTypeName(): string;
  66094. _draw(context: CanvasRenderingContext2D): void;
  66095. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66096. _measure(): void;
  66097. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66098. dispose(): void;
  66099. }
  66100. }
  66101. declare module BABYLON.GUI {
  66102. /**
  66103. * Class used to create radio button controls
  66104. */
  66105. export class RadioButton extends Control {
  66106. name?: string | undefined;
  66107. private _isChecked;
  66108. private _background;
  66109. private _checkSizeRatio;
  66110. private _thickness;
  66111. /** Gets or sets border thickness */
  66112. thickness: number;
  66113. /** Gets or sets group name */
  66114. group: string;
  66115. /** BABYLON.Observable raised when isChecked is changed */
  66116. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  66117. /** Gets or sets a value indicating the ratio between overall size and check size */
  66118. checkSizeRatio: number;
  66119. /** Gets or sets background color */
  66120. background: string;
  66121. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  66122. isChecked: boolean;
  66123. /**
  66124. * Creates a new RadioButton
  66125. * @param name defines the control name
  66126. */
  66127. constructor(name?: string | undefined);
  66128. protected _getTypeName(): string;
  66129. _draw(context: CanvasRenderingContext2D): void;
  66130. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66131. /**
  66132. * Utility function to easily create a radio button with a header
  66133. * @param title defines the label to use for the header
  66134. * @param group defines the group to use for the radio button
  66135. * @param isChecked defines the initial state of the radio button
  66136. * @param onValueChanged defines the callback to call when value changes
  66137. * @returns a StackPanel containing the radio button and a textBlock
  66138. */
  66139. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  66140. }
  66141. }
  66142. declare module BABYLON.GUI {
  66143. /**
  66144. * Class used to create slider controls
  66145. */
  66146. export class BaseSlider extends Control {
  66147. name?: string | undefined;
  66148. protected _thumbWidth: ValueAndUnit;
  66149. private _minimum;
  66150. private _maximum;
  66151. private _value;
  66152. private _isVertical;
  66153. protected _barOffset: ValueAndUnit;
  66154. private _isThumbClamped;
  66155. protected _displayThumb: boolean;
  66156. private _step;
  66157. private _lastPointerDownID;
  66158. protected _effectiveBarOffset: number;
  66159. protected _renderLeft: number;
  66160. protected _renderTop: number;
  66161. protected _renderWidth: number;
  66162. protected _renderHeight: number;
  66163. protected _backgroundBoxLength: number;
  66164. protected _backgroundBoxThickness: number;
  66165. protected _effectiveThumbThickness: number;
  66166. /** BABYLON.Observable raised when the sldier value changes */
  66167. onValueChangedObservable: BABYLON.Observable<number>;
  66168. /** Gets or sets a boolean indicating if the thumb must be rendered */
  66169. displayThumb: boolean;
  66170. /** Gets or sets a step to apply to values (0 by default) */
  66171. step: number;
  66172. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  66173. barOffset: string | number;
  66174. /** Gets main bar offset in pixels*/
  66175. readonly barOffsetInPixels: number;
  66176. /** Gets or sets thumb width */
  66177. thumbWidth: string | number;
  66178. /** Gets thumb width in pixels */
  66179. readonly thumbWidthInPixels: number;
  66180. /** Gets or sets minimum value */
  66181. minimum: number;
  66182. /** Gets or sets maximum value */
  66183. maximum: number;
  66184. /** Gets or sets current value */
  66185. value: number;
  66186. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  66187. isVertical: boolean;
  66188. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  66189. isThumbClamped: boolean;
  66190. /**
  66191. * Creates a new BaseSlider
  66192. * @param name defines the control name
  66193. */
  66194. constructor(name?: string | undefined);
  66195. protected _getTypeName(): string;
  66196. protected _getThumbPosition(): number;
  66197. protected _getThumbThickness(type: string): number;
  66198. protected _prepareRenderingData(type: string): void;
  66199. private _pointerIsDown;
  66200. /** @hidden */
  66201. protected _updateValueFromPointer(x: number, y: number): void;
  66202. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66203. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66204. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66205. }
  66206. }
  66207. declare module BABYLON.GUI {
  66208. /**
  66209. * Class used to create slider controls
  66210. */
  66211. export class Slider extends BaseSlider {
  66212. name?: string | undefined;
  66213. private _background;
  66214. private _borderColor;
  66215. private _isThumbCircle;
  66216. protected _displayValueBar: boolean;
  66217. /** Gets or sets a boolean indicating if the value bar must be rendered */
  66218. displayValueBar: boolean;
  66219. /** Gets or sets border color */
  66220. borderColor: string;
  66221. /** Gets or sets background color */
  66222. background: string;
  66223. /** Gets or sets a boolean indicating if the thumb should be round or square */
  66224. isThumbCircle: boolean;
  66225. /**
  66226. * Creates a new Slider
  66227. * @param name defines the control name
  66228. */
  66229. constructor(name?: string | undefined);
  66230. protected _getTypeName(): string;
  66231. _draw(context: CanvasRenderingContext2D): void;
  66232. }
  66233. }
  66234. declare module BABYLON.GUI {
  66235. /** Class used to create a RadioGroup
  66236. * which contains groups of radio buttons
  66237. */
  66238. export class SelectorGroup {
  66239. /** name of SelectorGroup */
  66240. name: string;
  66241. private _groupPanel;
  66242. private _selectors;
  66243. private _groupHeader;
  66244. /**
  66245. * Creates a new SelectorGroup
  66246. * @param name of group, used as a group heading
  66247. */
  66248. constructor(
  66249. /** name of SelectorGroup */
  66250. name: string);
  66251. /** Gets the groupPanel of the SelectorGroup */
  66252. readonly groupPanel: StackPanel;
  66253. /** Gets the selectors array */
  66254. readonly selectors: StackPanel[];
  66255. /** Gets and sets the group header */
  66256. header: string;
  66257. /** @hidden */
  66258. private _addGroupHeader;
  66259. /** @hidden*/
  66260. _getSelector(selectorNb: number): StackPanel | undefined;
  66261. /** Removes the selector at the given position
  66262. * @param selectorNb the position of the selector within the group
  66263. */
  66264. removeSelector(selectorNb: number): void;
  66265. }
  66266. /** Class used to create a CheckboxGroup
  66267. * which contains groups of checkbox buttons
  66268. */
  66269. export class CheckboxGroup extends SelectorGroup {
  66270. /** Adds a checkbox as a control
  66271. * @param text is the label for the selector
  66272. * @param func is the function called when the Selector is checked
  66273. * @param checked is true when Selector is checked
  66274. */
  66275. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  66276. /** @hidden */
  66277. _setSelectorLabel(selectorNb: number, label: string): void;
  66278. /** @hidden */
  66279. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66280. /** @hidden */
  66281. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66282. /** @hidden */
  66283. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66284. }
  66285. /** Class used to create a RadioGroup
  66286. * which contains groups of radio buttons
  66287. */
  66288. export class RadioGroup extends SelectorGroup {
  66289. private _selectNb;
  66290. /** Adds a radio button as a control
  66291. * @param label is the label for the selector
  66292. * @param func is the function called when the Selector is checked
  66293. * @param checked is true when Selector is checked
  66294. */
  66295. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  66296. /** @hidden */
  66297. _setSelectorLabel(selectorNb: number, label: string): void;
  66298. /** @hidden */
  66299. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66300. /** @hidden */
  66301. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66302. /** @hidden */
  66303. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66304. }
  66305. /** Class used to create a SliderGroup
  66306. * which contains groups of slider buttons
  66307. */
  66308. export class SliderGroup extends SelectorGroup {
  66309. /**
  66310. * Adds a slider to the SelectorGroup
  66311. * @param label is the label for the SliderBar
  66312. * @param func is the function called when the Slider moves
  66313. * @param unit is a string describing the units used, eg degrees or metres
  66314. * @param min is the minimum value for the Slider
  66315. * @param max is the maximum value for the Slider
  66316. * @param value is the start value for the Slider between min and max
  66317. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  66318. */
  66319. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  66320. /** @hidden */
  66321. _setSelectorLabel(selectorNb: number, label: string): void;
  66322. /** @hidden */
  66323. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66324. /** @hidden */
  66325. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66326. /** @hidden */
  66327. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66328. }
  66329. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  66330. * @see http://doc.babylonjs.com/how_to/selector
  66331. */
  66332. export class SelectionPanel extends Rectangle {
  66333. /** name of SelectionPanel */
  66334. name: string;
  66335. /** an array of SelectionGroups */
  66336. groups: SelectorGroup[];
  66337. private _panel;
  66338. private _buttonColor;
  66339. private _buttonBackground;
  66340. private _headerColor;
  66341. private _barColor;
  66342. private _barHeight;
  66343. private _spacerHeight;
  66344. private _labelColor;
  66345. private _groups;
  66346. private _bars;
  66347. /**
  66348. * Creates a new SelectionPanel
  66349. * @param name of SelectionPanel
  66350. * @param groups is an array of SelectionGroups
  66351. */
  66352. constructor(
  66353. /** name of SelectionPanel */
  66354. name: string,
  66355. /** an array of SelectionGroups */
  66356. groups?: SelectorGroup[]);
  66357. protected _getTypeName(): string;
  66358. /** Gets or sets the headerColor */
  66359. headerColor: string;
  66360. private _setHeaderColor;
  66361. /** Gets or sets the button color */
  66362. buttonColor: string;
  66363. private _setbuttonColor;
  66364. /** Gets or sets the label color */
  66365. labelColor: string;
  66366. private _setLabelColor;
  66367. /** Gets or sets the button background */
  66368. buttonBackground: string;
  66369. private _setButtonBackground;
  66370. /** Gets or sets the color of separator bar */
  66371. barColor: string;
  66372. private _setBarColor;
  66373. /** Gets or sets the height of separator bar */
  66374. barHeight: string;
  66375. private _setBarHeight;
  66376. /** Gets or sets the height of spacers*/
  66377. spacerHeight: string;
  66378. private _setSpacerHeight;
  66379. /** Adds a bar between groups */
  66380. private _addSpacer;
  66381. /** Add a group to the selection panel
  66382. * @param group is the selector group to add
  66383. */
  66384. addGroup(group: SelectorGroup): void;
  66385. /** Remove the group from the given position
  66386. * @param groupNb is the position of the group in the list
  66387. */
  66388. removeGroup(groupNb: number): void;
  66389. /** Change a group header label
  66390. * @param label is the new group header label
  66391. * @param groupNb is the number of the group to relabel
  66392. * */
  66393. setHeaderName(label: string, groupNb: number): void;
  66394. /** Change selector label to the one given
  66395. * @param label is the new selector label
  66396. * @param groupNb is the number of the groupcontaining the selector
  66397. * @param selectorNb is the number of the selector within a group to relabel
  66398. * */
  66399. relabel(label: string, groupNb: number, selectorNb: number): void;
  66400. /** For a given group position remove the selector at the given position
  66401. * @param groupNb is the number of the group to remove the selector from
  66402. * @param selectorNb is the number of the selector within the group
  66403. */
  66404. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  66405. /** For a given group position of correct type add a checkbox button
  66406. * @param groupNb is the number of the group to remove the selector from
  66407. * @param label is the label for the selector
  66408. * @param func is the function called when the Selector is checked
  66409. * @param checked is true when Selector is checked
  66410. */
  66411. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66412. /** For a given group position of correct type add a radio button
  66413. * @param groupNb is the number of the group to remove the selector from
  66414. * @param label is the label for the selector
  66415. * @param func is the function called when the Selector is checked
  66416. * @param checked is true when Selector is checked
  66417. */
  66418. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66419. /**
  66420. * For a given slider group add a slider
  66421. * @param groupNb is the number of the group to add the slider to
  66422. * @param label is the label for the Slider
  66423. * @param func is the function called when the Slider moves
  66424. * @param unit is a string describing the units used, eg degrees or metres
  66425. * @param min is the minimum value for the Slider
  66426. * @param max is the maximum value for the Slider
  66427. * @param value is the start value for the Slider between min and max
  66428. * @param onVal is the function used to format the value displayed, eg radians to degrees
  66429. */
  66430. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  66431. }
  66432. }
  66433. declare module BABYLON.GUI {
  66434. /**
  66435. * Class used to hold a the container for ScrollViewer
  66436. * @hidden
  66437. */
  66438. export class _ScrollViewerWindow extends Container {
  66439. parentClientWidth: number;
  66440. parentClientHeight: number;
  66441. /**
  66442. * Creates a new ScrollViewerWindow
  66443. * @param name of ScrollViewerWindow
  66444. */
  66445. constructor(name?: string);
  66446. protected _getTypeName(): string;
  66447. /** @hidden */
  66448. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66449. protected _postMeasure(): void;
  66450. }
  66451. }
  66452. declare module BABYLON.GUI {
  66453. /**
  66454. * Class used to create slider controls
  66455. */
  66456. export class ScrollBar extends BaseSlider {
  66457. name?: string | undefined;
  66458. private _background;
  66459. private _borderColor;
  66460. private _thumbMeasure;
  66461. /** Gets or sets border color */
  66462. borderColor: string;
  66463. /** Gets or sets background color */
  66464. background: string;
  66465. /**
  66466. * Creates a new Slider
  66467. * @param name defines the control name
  66468. */
  66469. constructor(name?: string | undefined);
  66470. protected _getTypeName(): string;
  66471. protected _getThumbThickness(): number;
  66472. _draw(context: CanvasRenderingContext2D): void;
  66473. private _first;
  66474. private _originX;
  66475. private _originY;
  66476. /** @hidden */
  66477. protected _updateValueFromPointer(x: number, y: number): void;
  66478. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66479. }
  66480. }
  66481. declare module BABYLON.GUI {
  66482. /**
  66483. * Class used to hold a viewer window and sliders in a grid
  66484. */
  66485. export class ScrollViewer extends Rectangle {
  66486. private _grid;
  66487. private _horizontalBarSpace;
  66488. private _verticalBarSpace;
  66489. private _dragSpace;
  66490. private _horizontalBar;
  66491. private _verticalBar;
  66492. private _barColor;
  66493. private _barBackground;
  66494. private _barSize;
  66495. private _endLeft;
  66496. private _endTop;
  66497. private _window;
  66498. private _pointerIsOver;
  66499. private _wheelPrecision;
  66500. private _onPointerObserver;
  66501. private _clientWidth;
  66502. private _clientHeight;
  66503. /**
  66504. * Gets the horizontal scrollbar
  66505. */
  66506. readonly horizontalBar: ScrollBar;
  66507. /**
  66508. * Gets the vertical scrollbar
  66509. */
  66510. readonly verticalBar: ScrollBar;
  66511. /**
  66512. * Adds a new control to the current container
  66513. * @param control defines the control to add
  66514. * @returns the current container
  66515. */
  66516. addControl(control: BABYLON.Nullable<Control>): Container;
  66517. /**
  66518. * Removes a control from the current container
  66519. * @param control defines the control to remove
  66520. * @returns the current container
  66521. */
  66522. removeControl(control: Control): Container;
  66523. /** Gets the list of children */
  66524. readonly children: Control[];
  66525. _flagDescendantsAsMatrixDirty(): void;
  66526. /**
  66527. * Creates a new ScrollViewer
  66528. * @param name of ScrollViewer
  66529. */
  66530. constructor(name?: string);
  66531. /** Reset the scroll viewer window to initial size */
  66532. resetWindow(): void;
  66533. protected _getTypeName(): string;
  66534. private _buildClientSizes;
  66535. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66536. protected _postMeasure(): void;
  66537. /**
  66538. * Gets or sets the mouse wheel precision
  66539. * from 0 to 1 with a default value of 0.05
  66540. * */
  66541. wheelPrecision: number;
  66542. /** Gets or sets the bar color */
  66543. barColor: string;
  66544. /** Gets or sets the size of the bar */
  66545. barSize: number;
  66546. /** Gets or sets the bar background */
  66547. barBackground: string;
  66548. /** @hidden */
  66549. private _updateScroller;
  66550. _link(host: AdvancedDynamicTexture): void;
  66551. /** @hidden */
  66552. private _attachWheel;
  66553. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66554. /** Releases associated resources */
  66555. dispose(): void;
  66556. }
  66557. }
  66558. declare module BABYLON.GUI {
  66559. /** Class used to render a grid */
  66560. export class DisplayGrid extends Control {
  66561. name?: string | undefined;
  66562. private _cellWidth;
  66563. private _cellHeight;
  66564. private _minorLineTickness;
  66565. private _minorLineColor;
  66566. private _majorLineTickness;
  66567. private _majorLineColor;
  66568. private _majorLineFrequency;
  66569. private _background;
  66570. private _displayMajorLines;
  66571. private _displayMinorLines;
  66572. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  66573. displayMinorLines: boolean;
  66574. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  66575. displayMajorLines: boolean;
  66576. /** Gets or sets background color (Black by default) */
  66577. background: string;
  66578. /** Gets or sets the width of each cell (20 by default) */
  66579. cellWidth: number;
  66580. /** Gets or sets the height of each cell (20 by default) */
  66581. cellHeight: number;
  66582. /** Gets or sets the tickness of minor lines (1 by default) */
  66583. minorLineTickness: number;
  66584. /** Gets or sets the color of minor lines (DarkGray by default) */
  66585. minorLineColor: string;
  66586. /** Gets or sets the tickness of major lines (2 by default) */
  66587. majorLineTickness: number;
  66588. /** Gets or sets the color of major lines (White by default) */
  66589. majorLineColor: string;
  66590. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  66591. majorLineFrequency: number;
  66592. /**
  66593. * Creates a new GridDisplayRectangle
  66594. * @param name defines the control name
  66595. */
  66596. constructor(name?: string | undefined);
  66597. _draw(context: CanvasRenderingContext2D): void;
  66598. protected _getTypeName(): string;
  66599. }
  66600. }
  66601. declare module BABYLON.GUI {
  66602. /**
  66603. * Class used to create slider controls based on images
  66604. */
  66605. export class ImageBasedSlider extends BaseSlider {
  66606. name?: string | undefined;
  66607. private _backgroundImage;
  66608. private _thumbImage;
  66609. private _valueBarImage;
  66610. private _tempMeasure;
  66611. displayThumb: boolean;
  66612. /**
  66613. * Gets or sets the image used to render the background
  66614. */
  66615. backgroundImage: Image;
  66616. /**
  66617. * Gets or sets the image used to render the value bar
  66618. */
  66619. valueBarImage: Image;
  66620. /**
  66621. * Gets or sets the image used to render the thumb
  66622. */
  66623. thumbImage: Image;
  66624. /**
  66625. * Creates a new ImageBasedSlider
  66626. * @param name defines the control name
  66627. */
  66628. constructor(name?: string | undefined);
  66629. protected _getTypeName(): string;
  66630. _draw(context: CanvasRenderingContext2D): void;
  66631. }
  66632. }
  66633. declare module BABYLON.GUI {
  66634. /**
  66635. * Forcing an export so that this code will execute
  66636. * @hidden
  66637. */
  66638. const name = "Statics";
  66639. }
  66640. declare module BABYLON.GUI {
  66641. /**
  66642. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  66643. */
  66644. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  66645. /**
  66646. * Define the instrumented AdvancedDynamicTexture.
  66647. */
  66648. texture: AdvancedDynamicTexture;
  66649. private _captureRenderTime;
  66650. private _renderTime;
  66651. private _captureLayoutTime;
  66652. private _layoutTime;
  66653. private _onBeginRenderObserver;
  66654. private _onEndRenderObserver;
  66655. private _onBeginLayoutObserver;
  66656. private _onEndLayoutObserver;
  66657. /**
  66658. * Gets the perf counter used to capture render time
  66659. */
  66660. readonly renderTimeCounter: BABYLON.PerfCounter;
  66661. /**
  66662. * Gets the perf counter used to capture layout time
  66663. */
  66664. readonly layoutTimeCounter: BABYLON.PerfCounter;
  66665. /**
  66666. * Enable or disable the render time capture
  66667. */
  66668. captureRenderTime: boolean;
  66669. /**
  66670. * Enable or disable the layout time capture
  66671. */
  66672. captureLayoutTime: boolean;
  66673. /**
  66674. * Instantiates a new advanced dynamic texture instrumentation.
  66675. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  66676. * @param texture Defines the AdvancedDynamicTexture to instrument
  66677. */
  66678. constructor(
  66679. /**
  66680. * Define the instrumented AdvancedDynamicTexture.
  66681. */
  66682. texture: AdvancedDynamicTexture);
  66683. /**
  66684. * Dispose and release associated resources.
  66685. */
  66686. dispose(): void;
  66687. }
  66688. }
  66689. declare module BABYLON.GUI {
  66690. /**
  66691. * Class used to load GUI via XML.
  66692. */
  66693. export class XmlLoader {
  66694. private _nodes;
  66695. private _nodeTypes;
  66696. private _isLoaded;
  66697. private _objectAttributes;
  66698. private _parentClass;
  66699. /**
  66700. * Create a new xml loader
  66701. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  66702. */
  66703. constructor(parentClass?: null);
  66704. private _getChainElement;
  66705. private _getClassAttribute;
  66706. private _createGuiElement;
  66707. private _parseGrid;
  66708. private _parseElement;
  66709. private _prepareSourceElement;
  66710. private _parseElementsFromSource;
  66711. private _parseXml;
  66712. /**
  66713. * Gets if the loading has finished.
  66714. * @returns whether the loading has finished or not
  66715. */
  66716. isLoaded(): boolean;
  66717. /**
  66718. * Gets a loaded node / control by id.
  66719. * @param id the Controls id set in the xml
  66720. * @returns element of type Control
  66721. */
  66722. getNodeById(id: string): any;
  66723. /**
  66724. * Gets all loaded nodes / controls
  66725. * @returns Array of controls
  66726. */
  66727. getNodes(): any;
  66728. /**
  66729. * Initiates the xml layout loading
  66730. * @param xmlFile defines the xml layout to load
  66731. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  66732. * @param callback defines the callback called on layout load.
  66733. */
  66734. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  66735. }
  66736. }
  66737. declare module BABYLON.GUI {
  66738. /**
  66739. * Class used to create containers for controls
  66740. */
  66741. export class Container3D extends Control3D {
  66742. private _blockLayout;
  66743. /**
  66744. * Gets the list of child controls
  66745. */
  66746. protected _children: Control3D[];
  66747. /**
  66748. * Gets the list of child controls
  66749. */
  66750. readonly children: Array<Control3D>;
  66751. /**
  66752. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  66753. * This is helpful to optimize layout operation when adding multiple children in a row
  66754. */
  66755. blockLayout: boolean;
  66756. /**
  66757. * Creates a new container
  66758. * @param name defines the container name
  66759. */
  66760. constructor(name?: string);
  66761. /**
  66762. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  66763. * @returns the current container
  66764. */
  66765. updateLayout(): Container3D;
  66766. /**
  66767. * Gets a boolean indicating if the given control is in the children of this control
  66768. * @param control defines the control to check
  66769. * @returns true if the control is in the child list
  66770. */
  66771. containsControl(control: Control3D): boolean;
  66772. /**
  66773. * Adds a control to the children of this control
  66774. * @param control defines the control to add
  66775. * @returns the current container
  66776. */
  66777. addControl(control: Control3D): Container3D;
  66778. /**
  66779. * This function will be called everytime a new control is added
  66780. */
  66781. protected _arrangeChildren(): void;
  66782. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66783. /**
  66784. * Removes a control from the children of this control
  66785. * @param control defines the control to remove
  66786. * @returns the current container
  66787. */
  66788. removeControl(control: Control3D): Container3D;
  66789. protected _getTypeName(): string;
  66790. /**
  66791. * Releases all associated resources
  66792. */
  66793. dispose(): void;
  66794. /** Control rotation will remain unchanged */
  66795. static readonly UNSET_ORIENTATION: number;
  66796. /** Control will rotate to make it look at sphere central axis */
  66797. static readonly FACEORIGIN_ORIENTATION: number;
  66798. /** Control will rotate to make it look back at sphere central axis */
  66799. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  66800. /** Control will rotate to look at z axis (0, 0, 1) */
  66801. static readonly FACEFORWARD_ORIENTATION: number;
  66802. /** Control will rotate to look at negative z axis (0, 0, -1) */
  66803. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  66804. }
  66805. }
  66806. declare module BABYLON.GUI {
  66807. /**
  66808. * Class used to manage 3D user interface
  66809. * @see http://doc.babylonjs.com/how_to/gui3d
  66810. */
  66811. export class GUI3DManager implements BABYLON.IDisposable {
  66812. private _scene;
  66813. private _sceneDisposeObserver;
  66814. private _utilityLayer;
  66815. private _rootContainer;
  66816. private _pointerObserver;
  66817. private _pointerOutObserver;
  66818. /** @hidden */
  66819. _lastPickedControl: Control3D;
  66820. /** @hidden */
  66821. _lastControlOver: {
  66822. [pointerId: number]: Control3D;
  66823. };
  66824. /** @hidden */
  66825. _lastControlDown: {
  66826. [pointerId: number]: Control3D;
  66827. };
  66828. /**
  66829. * BABYLON.Observable raised when the point picked by the pointer events changed
  66830. */
  66831. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  66832. /** @hidden */
  66833. _sharedMaterials: {
  66834. [key: string]: BABYLON.Material;
  66835. };
  66836. /** Gets the hosting scene */
  66837. readonly scene: BABYLON.Scene;
  66838. /** Gets associated utility layer */
  66839. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  66840. /**
  66841. * Creates a new GUI3DManager
  66842. * @param scene
  66843. */
  66844. constructor(scene?: BABYLON.Scene);
  66845. private _handlePointerOut;
  66846. private _doPicking;
  66847. /**
  66848. * Gets the root container
  66849. */
  66850. readonly rootContainer: Container3D;
  66851. /**
  66852. * Gets a boolean indicating if the given control is in the root child list
  66853. * @param control defines the control to check
  66854. * @returns true if the control is in the root child list
  66855. */
  66856. containsControl(control: Control3D): boolean;
  66857. /**
  66858. * Adds a control to the root child list
  66859. * @param control defines the control to add
  66860. * @returns the current manager
  66861. */
  66862. addControl(control: Control3D): GUI3DManager;
  66863. /**
  66864. * Removes a control from the root child list
  66865. * @param control defines the control to remove
  66866. * @returns the current container
  66867. */
  66868. removeControl(control: Control3D): GUI3DManager;
  66869. /**
  66870. * Releases all associated resources
  66871. */
  66872. dispose(): void;
  66873. }
  66874. }
  66875. declare module BABYLON.GUI {
  66876. /**
  66877. * Class used to transport BABYLON.Vector3 information for pointer events
  66878. */
  66879. export class Vector3WithInfo extends BABYLON.Vector3 {
  66880. /** defines the current mouse button index */
  66881. buttonIndex: number;
  66882. /**
  66883. * Creates a new Vector3WithInfo
  66884. * @param source defines the vector3 data to transport
  66885. * @param buttonIndex defines the current mouse button index
  66886. */
  66887. constructor(source: BABYLON.Vector3,
  66888. /** defines the current mouse button index */
  66889. buttonIndex?: number);
  66890. }
  66891. }
  66892. declare module BABYLON.GUI {
  66893. /**
  66894. * Class used as base class for controls
  66895. */
  66896. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  66897. /** Defines the control name */
  66898. name?: string | undefined;
  66899. /** @hidden */
  66900. _host: GUI3DManager;
  66901. private _node;
  66902. private _downCount;
  66903. private _enterCount;
  66904. private _downPointerIds;
  66905. private _isVisible;
  66906. /** Gets or sets the control position in world space */
  66907. position: BABYLON.Vector3;
  66908. /** Gets or sets the control scaling in world space */
  66909. scaling: BABYLON.Vector3;
  66910. /** Callback used to start pointer enter animation */
  66911. pointerEnterAnimation: () => void;
  66912. /** Callback used to start pointer out animation */
  66913. pointerOutAnimation: () => void;
  66914. /** Callback used to start pointer down animation */
  66915. pointerDownAnimation: () => void;
  66916. /** Callback used to start pointer up animation */
  66917. pointerUpAnimation: () => void;
  66918. /**
  66919. * An event triggered when the pointer move over the control
  66920. */
  66921. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  66922. /**
  66923. * An event triggered when the pointer move out of the control
  66924. */
  66925. onPointerOutObservable: BABYLON.Observable<Control3D>;
  66926. /**
  66927. * An event triggered when the pointer taps the control
  66928. */
  66929. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  66930. /**
  66931. * An event triggered when pointer is up
  66932. */
  66933. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  66934. /**
  66935. * An event triggered when a control is clicked on (with a mouse)
  66936. */
  66937. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  66938. /**
  66939. * An event triggered when pointer enters the control
  66940. */
  66941. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  66942. /**
  66943. * Gets or sets the parent container
  66944. */
  66945. parent: BABYLON.Nullable<Container3D>;
  66946. private _behaviors;
  66947. /**
  66948. * Gets the list of attached behaviors
  66949. * @see http://doc.babylonjs.com/features/behaviour
  66950. */
  66951. readonly behaviors: BABYLON.Behavior<Control3D>[];
  66952. /**
  66953. * Attach a behavior to the control
  66954. * @see http://doc.babylonjs.com/features/behaviour
  66955. * @param behavior defines the behavior to attach
  66956. * @returns the current control
  66957. */
  66958. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66959. /**
  66960. * Remove an attached behavior
  66961. * @see http://doc.babylonjs.com/features/behaviour
  66962. * @param behavior defines the behavior to attach
  66963. * @returns the current control
  66964. */
  66965. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66966. /**
  66967. * Gets an attached behavior by name
  66968. * @param name defines the name of the behavior to look for
  66969. * @see http://doc.babylonjs.com/features/behaviour
  66970. * @returns null if behavior was not found else the requested behavior
  66971. */
  66972. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  66973. /** Gets or sets a boolean indicating if the control is visible */
  66974. isVisible: boolean;
  66975. /**
  66976. * Creates a new control
  66977. * @param name defines the control name
  66978. */
  66979. constructor(
  66980. /** Defines the control name */
  66981. name?: string | undefined);
  66982. /**
  66983. * Gets a string representing the class name
  66984. */
  66985. readonly typeName: string;
  66986. /**
  66987. * Get the current class name of the control.
  66988. * @returns current class name
  66989. */
  66990. getClassName(): string;
  66991. protected _getTypeName(): string;
  66992. /**
  66993. * Gets the transform node used by this control
  66994. */
  66995. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  66996. /**
  66997. * Gets the mesh used to render this control
  66998. */
  66999. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67000. /**
  67001. * Link the control as child of the given node
  67002. * @param node defines the node to link to. Use null to unlink the control
  67003. * @returns the current control
  67004. */
  67005. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  67006. /** @hidden **/
  67007. _prepareNode(scene: BABYLON.Scene): void;
  67008. /**
  67009. * Node creation.
  67010. * Can be overriden by children
  67011. * @param scene defines the scene where the node must be attached
  67012. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  67013. */
  67014. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  67015. /**
  67016. * Affect a material to the given mesh
  67017. * @param mesh defines the mesh which will represent the control
  67018. */
  67019. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67020. /** @hidden */
  67021. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  67022. /** @hidden */
  67023. _onPointerEnter(target: Control3D): boolean;
  67024. /** @hidden */
  67025. _onPointerOut(target: Control3D): void;
  67026. /** @hidden */
  67027. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  67028. /** @hidden */
  67029. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67030. /** @hidden */
  67031. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  67032. /** @hidden */
  67033. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  67034. /** @hidden */
  67035. _disposeNode(): void;
  67036. /**
  67037. * Releases all associated resources
  67038. */
  67039. dispose(): void;
  67040. }
  67041. }
  67042. declare module BABYLON.GUI {
  67043. /**
  67044. * Class used as a root to all buttons
  67045. */
  67046. export class AbstractButton3D extends Control3D {
  67047. /**
  67048. * Creates a new button
  67049. * @param name defines the control name
  67050. */
  67051. constructor(name?: string);
  67052. protected _getTypeName(): string;
  67053. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67054. }
  67055. }
  67056. declare module BABYLON.GUI {
  67057. /**
  67058. * Class used to create a button in 3D
  67059. */
  67060. export class Button3D extends AbstractButton3D {
  67061. /** @hidden */
  67062. protected _currentMaterial: BABYLON.Material;
  67063. private _facadeTexture;
  67064. private _content;
  67065. private _contentResolution;
  67066. private _contentScaleRatio;
  67067. /**
  67068. * Gets or sets the texture resolution used to render content (512 by default)
  67069. */
  67070. contentResolution: BABYLON.int;
  67071. /**
  67072. * Gets or sets the texture scale ratio used to render content (2 by default)
  67073. */
  67074. contentScaleRatio: number;
  67075. protected _disposeFacadeTexture(): void;
  67076. protected _resetContent(): void;
  67077. /**
  67078. * Creates a new button
  67079. * @param name defines the control name
  67080. */
  67081. constructor(name?: string);
  67082. /**
  67083. * Gets or sets the GUI 2D content used to display the button's facade
  67084. */
  67085. content: Control;
  67086. /**
  67087. * Apply the facade texture (created from the content property).
  67088. * This function can be overloaded by child classes
  67089. * @param facadeTexture defines the AdvancedDynamicTexture to use
  67090. */
  67091. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67092. protected _getTypeName(): string;
  67093. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67094. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67095. /**
  67096. * Releases all associated resources
  67097. */
  67098. dispose(): void;
  67099. }
  67100. }
  67101. declare module BABYLON.GUI {
  67102. /**
  67103. * Abstract class used to create a container panel deployed on the surface of a volume
  67104. */
  67105. export abstract class VolumeBasedPanel extends Container3D {
  67106. private _columns;
  67107. private _rows;
  67108. private _rowThenColum;
  67109. private _orientation;
  67110. protected _cellWidth: number;
  67111. protected _cellHeight: number;
  67112. /**
  67113. * Gets or sets the distance between elements
  67114. */
  67115. margin: number;
  67116. /**
  67117. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  67118. * | Value | Type | Description |
  67119. * | ----- | ----------------------------------- | ----------- |
  67120. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  67121. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  67122. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  67123. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  67124. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  67125. */
  67126. orientation: number;
  67127. /**
  67128. * Gets or sets the number of columns requested (10 by default).
  67129. * The panel will automatically compute the number of rows based on number of child controls.
  67130. */
  67131. columns: BABYLON.int;
  67132. /**
  67133. * Gets or sets a the number of rows requested.
  67134. * The panel will automatically compute the number of columns based on number of child controls.
  67135. */
  67136. rows: BABYLON.int;
  67137. /**
  67138. * Creates new VolumeBasedPanel
  67139. */
  67140. constructor();
  67141. protected _arrangeChildren(): void;
  67142. /** Child classes must implement this function to provide correct control positioning */
  67143. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67144. /** Child classes can implement this function to provide additional processing */
  67145. protected _finalProcessing(): void;
  67146. }
  67147. }
  67148. declare module BABYLON.GUI {
  67149. /**
  67150. * Class used to create a container panel deployed on the surface of a cylinder
  67151. */
  67152. export class CylinderPanel extends VolumeBasedPanel {
  67153. private _radius;
  67154. /**
  67155. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  67156. */
  67157. radius: BABYLON.float;
  67158. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67159. private _cylindricalMapping;
  67160. }
  67161. }
  67162. declare module BABYLON.GUI {
  67163. /** @hidden */
  67164. export var fluentVertexShader: {
  67165. name: string;
  67166. shader: string;
  67167. };
  67168. }
  67169. declare module BABYLON.GUI {
  67170. /** @hidden */
  67171. export var fluentPixelShader: {
  67172. name: string;
  67173. shader: string;
  67174. };
  67175. }
  67176. declare module BABYLON.GUI {
  67177. /** @hidden */
  67178. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  67179. INNERGLOW: boolean;
  67180. BORDER: boolean;
  67181. HOVERLIGHT: boolean;
  67182. TEXTURE: boolean;
  67183. constructor();
  67184. }
  67185. /**
  67186. * Class used to render controls with fluent desgin
  67187. */
  67188. export class FluentMaterial extends BABYLON.PushMaterial {
  67189. /**
  67190. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  67191. */
  67192. innerGlowColorIntensity: number;
  67193. /**
  67194. * Gets or sets the inner glow color (white by default)
  67195. */
  67196. innerGlowColor: BABYLON.Color3;
  67197. /**
  67198. * Gets or sets alpha value (default is 1.0)
  67199. */
  67200. alpha: number;
  67201. /**
  67202. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  67203. */
  67204. albedoColor: BABYLON.Color3;
  67205. /**
  67206. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  67207. */
  67208. renderBorders: boolean;
  67209. /**
  67210. * Gets or sets border width (default is 0.5)
  67211. */
  67212. borderWidth: number;
  67213. /**
  67214. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  67215. */
  67216. edgeSmoothingValue: number;
  67217. /**
  67218. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  67219. */
  67220. borderMinValue: number;
  67221. /**
  67222. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  67223. */
  67224. renderHoverLight: boolean;
  67225. /**
  67226. * Gets or sets the radius used to render the hover light (default is 1.0)
  67227. */
  67228. hoverRadius: number;
  67229. /**
  67230. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  67231. */
  67232. hoverColor: BABYLON.Color4;
  67233. /**
  67234. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  67235. */
  67236. hoverPosition: BABYLON.Vector3;
  67237. private _albedoTexture;
  67238. /** Gets or sets the texture to use for albedo color */
  67239. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67240. /**
  67241. * Creates a new Fluent material
  67242. * @param name defines the name of the material
  67243. * @param scene defines the hosting scene
  67244. */
  67245. constructor(name: string, scene: BABYLON.Scene);
  67246. needAlphaBlending(): boolean;
  67247. needAlphaTesting(): boolean;
  67248. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67249. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67250. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67251. getActiveTextures(): BABYLON.BaseTexture[];
  67252. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67253. dispose(forceDisposeEffect?: boolean): void;
  67254. clone(name: string): FluentMaterial;
  67255. serialize(): any;
  67256. getClassName(): string;
  67257. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  67258. }
  67259. }
  67260. declare module BABYLON.GUI {
  67261. /**
  67262. * Class used to create a holographic button in 3D
  67263. */
  67264. export class HolographicButton extends Button3D {
  67265. private _backPlate;
  67266. private _textPlate;
  67267. private _frontPlate;
  67268. private _text;
  67269. private _imageUrl;
  67270. private _shareMaterials;
  67271. private _frontMaterial;
  67272. private _backMaterial;
  67273. private _plateMaterial;
  67274. private _pickedPointObserver;
  67275. private _tooltipFade;
  67276. private _tooltipTextBlock;
  67277. private _tooltipTexture;
  67278. private _tooltipMesh;
  67279. private _tooltipHoverObserver;
  67280. private _tooltipOutObserver;
  67281. private _disposeTooltip;
  67282. /**
  67283. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  67284. */
  67285. tooltipText: BABYLON.Nullable<string>;
  67286. /**
  67287. * Gets or sets text for the button
  67288. */
  67289. text: string;
  67290. /**
  67291. * Gets or sets the image url for the button
  67292. */
  67293. imageUrl: string;
  67294. /**
  67295. * Gets the back material used by this button
  67296. */
  67297. readonly backMaterial: FluentMaterial;
  67298. /**
  67299. * Gets the front material used by this button
  67300. */
  67301. readonly frontMaterial: FluentMaterial;
  67302. /**
  67303. * Gets the plate material used by this button
  67304. */
  67305. readonly plateMaterial: BABYLON.StandardMaterial;
  67306. /**
  67307. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  67308. */
  67309. readonly shareMaterials: boolean;
  67310. /**
  67311. * Creates a new button
  67312. * @param name defines the control name
  67313. */
  67314. constructor(name?: string, shareMaterials?: boolean);
  67315. protected _getTypeName(): string;
  67316. private _rebuildContent;
  67317. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67318. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67319. private _createBackMaterial;
  67320. private _createFrontMaterial;
  67321. private _createPlateMaterial;
  67322. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  67323. /**
  67324. * Releases all associated resources
  67325. */
  67326. dispose(): void;
  67327. }
  67328. }
  67329. declare module BABYLON.GUI {
  67330. /**
  67331. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  67332. */
  67333. export class MeshButton3D extends Button3D {
  67334. /** @hidden */
  67335. protected _currentMesh: BABYLON.Mesh;
  67336. /**
  67337. * Creates a new 3D button based on a mesh
  67338. * @param mesh mesh to become a 3D button
  67339. * @param name defines the control name
  67340. */
  67341. constructor(mesh: BABYLON.Mesh, name?: string);
  67342. protected _getTypeName(): string;
  67343. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67344. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67345. }
  67346. }
  67347. declare module BABYLON.GUI {
  67348. /**
  67349. * Class used to create a container panel deployed on the surface of a plane
  67350. */
  67351. export class PlanePanel extends VolumeBasedPanel {
  67352. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67353. }
  67354. }
  67355. declare module BABYLON.GUI {
  67356. /**
  67357. * Class used to create a container panel where items get randomized planar mapping
  67358. */
  67359. export class ScatterPanel extends VolumeBasedPanel {
  67360. private _iteration;
  67361. /**
  67362. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  67363. */
  67364. iteration: BABYLON.float;
  67365. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67366. private _scatterMapping;
  67367. protected _finalProcessing(): void;
  67368. }
  67369. }
  67370. declare module BABYLON.GUI {
  67371. /**
  67372. * Class used to create a container panel deployed on the surface of a sphere
  67373. */
  67374. export class SpherePanel extends VolumeBasedPanel {
  67375. private _radius;
  67376. /**
  67377. * Gets or sets the radius of the sphere where to project controls (5 by default)
  67378. */
  67379. radius: BABYLON.float;
  67380. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67381. private _sphericalMapping;
  67382. }
  67383. }
  67384. declare module BABYLON.GUI {
  67385. /**
  67386. * Class used to create a stack panel in 3D on XY plane
  67387. */
  67388. export class StackPanel3D extends Container3D {
  67389. private _isVertical;
  67390. /**
  67391. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  67392. */
  67393. isVertical: boolean;
  67394. /**
  67395. * Gets or sets the distance between elements
  67396. */
  67397. margin: number;
  67398. /**
  67399. * Creates new StackPanel
  67400. * @param isVertical
  67401. */
  67402. constructor(isVertical?: boolean);
  67403. protected _arrangeChildren(): void;
  67404. }
  67405. }
  67406. declare module BABYLON {
  67407. /**
  67408. * Mode that determines the coordinate system to use.
  67409. */
  67410. export enum GLTFLoaderCoordinateSystemMode {
  67411. /**
  67412. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  67413. */
  67414. AUTO = 0,
  67415. /**
  67416. * Sets the useRightHandedSystem flag on the scene.
  67417. */
  67418. FORCE_RIGHT_HANDED = 1
  67419. }
  67420. /**
  67421. * Mode that determines what animations will start.
  67422. */
  67423. export enum GLTFLoaderAnimationStartMode {
  67424. /**
  67425. * No animation will start.
  67426. */
  67427. NONE = 0,
  67428. /**
  67429. * The first animation will start.
  67430. */
  67431. FIRST = 1,
  67432. /**
  67433. * All animations will start.
  67434. */
  67435. ALL = 2
  67436. }
  67437. /**
  67438. * Interface that contains the data for the glTF asset.
  67439. */
  67440. export interface IGLTFLoaderData {
  67441. /**
  67442. * Object that represents the glTF JSON.
  67443. */
  67444. json: Object;
  67445. /**
  67446. * The BIN chunk of a binary glTF.
  67447. */
  67448. bin: Nullable<ArrayBufferView>;
  67449. }
  67450. /**
  67451. * Interface for extending the loader.
  67452. */
  67453. export interface IGLTFLoaderExtension {
  67454. /**
  67455. * The name of this extension.
  67456. */
  67457. readonly name: string;
  67458. /**
  67459. * Defines whether this extension is enabled.
  67460. */
  67461. enabled: boolean;
  67462. }
  67463. /**
  67464. * Loader state.
  67465. */
  67466. export enum GLTFLoaderState {
  67467. /**
  67468. * The asset is loading.
  67469. */
  67470. LOADING = 0,
  67471. /**
  67472. * The asset is ready for rendering.
  67473. */
  67474. READY = 1,
  67475. /**
  67476. * The asset is completely loaded.
  67477. */
  67478. COMPLETE = 2
  67479. }
  67480. /** @hidden */
  67481. export interface IGLTFLoader extends IDisposable {
  67482. readonly state: Nullable<GLTFLoaderState>;
  67483. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  67484. meshes: AbstractMesh[];
  67485. particleSystems: IParticleSystem[];
  67486. skeletons: Skeleton[];
  67487. animationGroups: AnimationGroup[];
  67488. }>;
  67489. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  67490. }
  67491. /**
  67492. * File loader for loading glTF files into a scene.
  67493. */
  67494. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67495. /** @hidden */
  67496. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67497. /** @hidden */
  67498. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67499. /**
  67500. * Raised when the asset has been parsed
  67501. */
  67502. onParsedObservable: Observable<IGLTFLoaderData>;
  67503. private _onParsedObserver;
  67504. /**
  67505. * Raised when the asset has been parsed
  67506. */
  67507. onParsed: (loaderData: IGLTFLoaderData) => void;
  67508. /**
  67509. * 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.
  67510. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  67511. * Defaults to true.
  67512. * @hidden
  67513. */
  67514. static IncrementalLoading: boolean;
  67515. /**
  67516. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  67517. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  67518. * @hidden
  67519. */
  67520. static HomogeneousCoordinates: boolean;
  67521. /**
  67522. * The coordinate system mode. Defaults to AUTO.
  67523. */
  67524. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  67525. /**
  67526. * The animation start mode. Defaults to FIRST.
  67527. */
  67528. animationStartMode: GLTFLoaderAnimationStartMode;
  67529. /**
  67530. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  67531. */
  67532. compileMaterials: boolean;
  67533. /**
  67534. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  67535. */
  67536. useClipPlane: boolean;
  67537. /**
  67538. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  67539. */
  67540. compileShadowGenerators: boolean;
  67541. /**
  67542. * Defines if the Alpha blended materials are only applied as coverage.
  67543. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  67544. * If true, no extra effects are applied to transparent pixels.
  67545. */
  67546. transparencyAsCoverage: boolean;
  67547. /**
  67548. * Function called before loading a url referenced by the asset.
  67549. */
  67550. preprocessUrlAsync: (url: string) => Promise<string>;
  67551. /**
  67552. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67553. */
  67554. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  67555. private _onMeshLoadedObserver;
  67556. /**
  67557. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67558. */
  67559. onMeshLoaded: (mesh: AbstractMesh) => void;
  67560. /**
  67561. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  67562. */
  67563. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  67564. private _onTextureLoadedObserver;
  67565. /**
  67566. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  67567. */
  67568. onTextureLoaded: (texture: BaseTexture) => void;
  67569. /**
  67570. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  67571. */
  67572. readonly onMaterialLoadedObservable: Observable<Material>;
  67573. private _onMaterialLoadedObserver;
  67574. /**
  67575. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  67576. */
  67577. onMaterialLoaded: (material: Material) => void;
  67578. /**
  67579. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  67580. */
  67581. readonly onCameraLoadedObservable: Observable<Camera>;
  67582. private _onCameraLoadedObserver;
  67583. /**
  67584. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  67585. */
  67586. onCameraLoaded: (camera: Camera) => void;
  67587. /**
  67588. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  67589. * For assets with LODs, raised when all of the LODs are complete.
  67590. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67591. */
  67592. readonly onCompleteObservable: Observable<void>;
  67593. private _onCompleteObserver;
  67594. /**
  67595. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  67596. * For assets with LODs, raised when all of the LODs are complete.
  67597. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67598. */
  67599. onComplete: () => void;
  67600. /**
  67601. * Observable raised when an error occurs.
  67602. */
  67603. readonly onErrorObservable: Observable<any>;
  67604. private _onErrorObserver;
  67605. /**
  67606. * Callback raised when an error occurs.
  67607. */
  67608. onError: (reason: any) => void;
  67609. /**
  67610. * Observable raised after the loader is disposed.
  67611. */
  67612. readonly onDisposeObservable: Observable<void>;
  67613. private _onDisposeObserver;
  67614. /**
  67615. * Callback raised after the loader is disposed.
  67616. */
  67617. onDispose: () => void;
  67618. /**
  67619. * Observable raised after a loader extension is created.
  67620. * Set additional options for a loader extension in this event.
  67621. */
  67622. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  67623. private _onExtensionLoadedObserver;
  67624. /**
  67625. * Callback raised after a loader extension is created.
  67626. */
  67627. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  67628. /**
  67629. * Defines if the loader logging is enabled.
  67630. */
  67631. loggingEnabled: boolean;
  67632. /**
  67633. * Defines if the loader should capture performance counters.
  67634. */
  67635. capturePerformanceCounters: boolean;
  67636. /**
  67637. * Defines if the loader should validate the asset.
  67638. */
  67639. validate: boolean;
  67640. /**
  67641. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  67642. */
  67643. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  67644. private _onValidatedObserver;
  67645. /**
  67646. * Callback raised after a loader extension is created.
  67647. */
  67648. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  67649. private _loader;
  67650. /**
  67651. * Name of the loader ("gltf")
  67652. */
  67653. name: string;
  67654. /**
  67655. * Supported file extensions of the loader (.gltf, .glb)
  67656. */
  67657. extensions: ISceneLoaderPluginExtensions;
  67658. /**
  67659. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  67660. */
  67661. dispose(): void;
  67662. /** @hidden */
  67663. _clear(): void;
  67664. /**
  67665. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  67666. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67667. * @param scene the scene the meshes should be added to
  67668. * @param data the glTF data to load
  67669. * @param rootUrl root url to load from
  67670. * @param onProgress event that fires when loading progress has occured
  67671. * @param fileName Defines the name of the file to load
  67672. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67673. */
  67674. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67675. meshes: AbstractMesh[];
  67676. particleSystems: IParticleSystem[];
  67677. skeletons: Skeleton[];
  67678. animationGroups: AnimationGroup[];
  67679. }>;
  67680. /**
  67681. * Imports all objects from the loaded glTF data and adds them to the scene
  67682. * @param scene the scene the objects should be added to
  67683. * @param data the glTF data to load
  67684. * @param rootUrl root url to load from
  67685. * @param onProgress event that fires when loading progress has occured
  67686. * @param fileName Defines the name of the file to load
  67687. * @returns a promise which completes when objects have been loaded to the scene
  67688. */
  67689. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67690. /**
  67691. * Load into an asset container.
  67692. * @param scene The scene to load into
  67693. * @param data The data to import
  67694. * @param rootUrl The root url for scene and resources
  67695. * @param onProgress The callback when the load progresses
  67696. * @param fileName Defines the name of the file to load
  67697. * @returns The loaded asset container
  67698. */
  67699. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67700. /**
  67701. * If the data string can be loaded directly.
  67702. * @param data string contianing the file data
  67703. * @returns if the data can be loaded directly
  67704. */
  67705. canDirectLoad(data: string): boolean;
  67706. /**
  67707. * Rewrites a url by combining a root url and response url.
  67708. */
  67709. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  67710. /**
  67711. * Instantiates a glTF file loader plugin.
  67712. * @returns the created plugin
  67713. */
  67714. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  67715. /**
  67716. * The loader state or null if the loader is not active.
  67717. */
  67718. readonly loaderState: Nullable<GLTFLoaderState>;
  67719. /**
  67720. * Returns a promise that resolves when the asset is completely loaded.
  67721. * @returns a promise that resolves when the asset is completely loaded.
  67722. */
  67723. whenCompleteAsync(): Promise<void>;
  67724. private _parseAsync;
  67725. private _validateAsync;
  67726. private _getLoader;
  67727. private _unpackBinary;
  67728. private _unpackBinaryV1;
  67729. private _unpackBinaryV2;
  67730. private static _parseVersion;
  67731. private static _compareVersion;
  67732. private static _decodeBufferToText;
  67733. private static readonly _logSpaces;
  67734. private _logIndentLevel;
  67735. private _loggingEnabled;
  67736. /** @hidden */
  67737. _log: (message: string) => void;
  67738. /** @hidden */
  67739. _logOpen(message: string): void;
  67740. /** @hidden */
  67741. _logClose(): void;
  67742. private _logEnabled;
  67743. private _logDisabled;
  67744. private _capturePerformanceCounters;
  67745. /** @hidden */
  67746. _startPerformanceCounter: (counterName: string) => void;
  67747. /** @hidden */
  67748. _endPerformanceCounter: (counterName: string) => void;
  67749. private _startPerformanceCounterEnabled;
  67750. private _startPerformanceCounterDisabled;
  67751. private _endPerformanceCounterEnabled;
  67752. private _endPerformanceCounterDisabled;
  67753. }
  67754. }
  67755. declare module BABYLON.GLTF1 {
  67756. /**
  67757. * Enums
  67758. * @hidden
  67759. */
  67760. export enum EComponentType {
  67761. BYTE = 5120,
  67762. UNSIGNED_BYTE = 5121,
  67763. SHORT = 5122,
  67764. UNSIGNED_SHORT = 5123,
  67765. FLOAT = 5126
  67766. }
  67767. /** @hidden */
  67768. export enum EShaderType {
  67769. FRAGMENT = 35632,
  67770. VERTEX = 35633
  67771. }
  67772. /** @hidden */
  67773. export enum EParameterType {
  67774. BYTE = 5120,
  67775. UNSIGNED_BYTE = 5121,
  67776. SHORT = 5122,
  67777. UNSIGNED_SHORT = 5123,
  67778. INT = 5124,
  67779. UNSIGNED_INT = 5125,
  67780. FLOAT = 5126,
  67781. FLOAT_VEC2 = 35664,
  67782. FLOAT_VEC3 = 35665,
  67783. FLOAT_VEC4 = 35666,
  67784. INT_VEC2 = 35667,
  67785. INT_VEC3 = 35668,
  67786. INT_VEC4 = 35669,
  67787. BOOL = 35670,
  67788. BOOL_VEC2 = 35671,
  67789. BOOL_VEC3 = 35672,
  67790. BOOL_VEC4 = 35673,
  67791. FLOAT_MAT2 = 35674,
  67792. FLOAT_MAT3 = 35675,
  67793. FLOAT_MAT4 = 35676,
  67794. SAMPLER_2D = 35678
  67795. }
  67796. /** @hidden */
  67797. export enum ETextureWrapMode {
  67798. CLAMP_TO_EDGE = 33071,
  67799. MIRRORED_REPEAT = 33648,
  67800. REPEAT = 10497
  67801. }
  67802. /** @hidden */
  67803. export enum ETextureFilterType {
  67804. NEAREST = 9728,
  67805. LINEAR = 9728,
  67806. NEAREST_MIPMAP_NEAREST = 9984,
  67807. LINEAR_MIPMAP_NEAREST = 9985,
  67808. NEAREST_MIPMAP_LINEAR = 9986,
  67809. LINEAR_MIPMAP_LINEAR = 9987
  67810. }
  67811. /** @hidden */
  67812. export enum ETextureFormat {
  67813. ALPHA = 6406,
  67814. RGB = 6407,
  67815. RGBA = 6408,
  67816. LUMINANCE = 6409,
  67817. LUMINANCE_ALPHA = 6410
  67818. }
  67819. /** @hidden */
  67820. export enum ECullingType {
  67821. FRONT = 1028,
  67822. BACK = 1029,
  67823. FRONT_AND_BACK = 1032
  67824. }
  67825. /** @hidden */
  67826. export enum EBlendingFunction {
  67827. ZERO = 0,
  67828. ONE = 1,
  67829. SRC_COLOR = 768,
  67830. ONE_MINUS_SRC_COLOR = 769,
  67831. DST_COLOR = 774,
  67832. ONE_MINUS_DST_COLOR = 775,
  67833. SRC_ALPHA = 770,
  67834. ONE_MINUS_SRC_ALPHA = 771,
  67835. DST_ALPHA = 772,
  67836. ONE_MINUS_DST_ALPHA = 773,
  67837. CONSTANT_COLOR = 32769,
  67838. ONE_MINUS_CONSTANT_COLOR = 32770,
  67839. CONSTANT_ALPHA = 32771,
  67840. ONE_MINUS_CONSTANT_ALPHA = 32772,
  67841. SRC_ALPHA_SATURATE = 776
  67842. }
  67843. /** @hidden */
  67844. export interface IGLTFProperty {
  67845. extensions?: {
  67846. [key: string]: any;
  67847. };
  67848. extras?: Object;
  67849. }
  67850. /** @hidden */
  67851. export interface IGLTFChildRootProperty extends IGLTFProperty {
  67852. name?: string;
  67853. }
  67854. /** @hidden */
  67855. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  67856. bufferView: string;
  67857. byteOffset: number;
  67858. byteStride: number;
  67859. count: number;
  67860. type: string;
  67861. componentType: EComponentType;
  67862. max?: number[];
  67863. min?: number[];
  67864. name?: string;
  67865. }
  67866. /** @hidden */
  67867. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  67868. buffer: string;
  67869. byteOffset: number;
  67870. byteLength: number;
  67871. byteStride: number;
  67872. target?: number;
  67873. }
  67874. /** @hidden */
  67875. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  67876. uri: string;
  67877. byteLength?: number;
  67878. type?: string;
  67879. }
  67880. /** @hidden */
  67881. export interface IGLTFShader extends IGLTFChildRootProperty {
  67882. uri: string;
  67883. type: EShaderType;
  67884. }
  67885. /** @hidden */
  67886. export interface IGLTFProgram extends IGLTFChildRootProperty {
  67887. attributes: string[];
  67888. fragmentShader: string;
  67889. vertexShader: string;
  67890. }
  67891. /** @hidden */
  67892. export interface IGLTFTechniqueParameter {
  67893. type: number;
  67894. count?: number;
  67895. semantic?: string;
  67896. node?: string;
  67897. value?: number | boolean | string | Array<any>;
  67898. source?: string;
  67899. babylonValue?: any;
  67900. }
  67901. /** @hidden */
  67902. export interface IGLTFTechniqueCommonProfile {
  67903. lightingModel: string;
  67904. texcoordBindings: Object;
  67905. parameters?: Array<any>;
  67906. }
  67907. /** @hidden */
  67908. export interface IGLTFTechniqueStatesFunctions {
  67909. blendColor?: number[];
  67910. blendEquationSeparate?: number[];
  67911. blendFuncSeparate?: number[];
  67912. colorMask: boolean[];
  67913. cullFace: number[];
  67914. }
  67915. /** @hidden */
  67916. export interface IGLTFTechniqueStates {
  67917. enable: number[];
  67918. functions: IGLTFTechniqueStatesFunctions;
  67919. }
  67920. /** @hidden */
  67921. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  67922. parameters: {
  67923. [key: string]: IGLTFTechniqueParameter;
  67924. };
  67925. program: string;
  67926. attributes: {
  67927. [key: string]: string;
  67928. };
  67929. uniforms: {
  67930. [key: string]: string;
  67931. };
  67932. states: IGLTFTechniqueStates;
  67933. }
  67934. /** @hidden */
  67935. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  67936. technique?: string;
  67937. values: string[];
  67938. }
  67939. /** @hidden */
  67940. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  67941. attributes: {
  67942. [key: string]: string;
  67943. };
  67944. indices: string;
  67945. material: string;
  67946. mode?: number;
  67947. }
  67948. /** @hidden */
  67949. export interface IGLTFMesh extends IGLTFChildRootProperty {
  67950. primitives: IGLTFMeshPrimitive[];
  67951. }
  67952. /** @hidden */
  67953. export interface IGLTFImage extends IGLTFChildRootProperty {
  67954. uri: string;
  67955. }
  67956. /** @hidden */
  67957. export interface IGLTFSampler extends IGLTFChildRootProperty {
  67958. magFilter?: number;
  67959. minFilter?: number;
  67960. wrapS?: number;
  67961. wrapT?: number;
  67962. }
  67963. /** @hidden */
  67964. export interface IGLTFTexture extends IGLTFChildRootProperty {
  67965. sampler: string;
  67966. source: string;
  67967. format?: ETextureFormat;
  67968. internalFormat?: ETextureFormat;
  67969. target?: number;
  67970. type?: number;
  67971. babylonTexture?: Texture;
  67972. }
  67973. /** @hidden */
  67974. export interface IGLTFAmbienLight {
  67975. color?: number[];
  67976. }
  67977. /** @hidden */
  67978. export interface IGLTFDirectionalLight {
  67979. color?: number[];
  67980. }
  67981. /** @hidden */
  67982. export interface IGLTFPointLight {
  67983. color?: number[];
  67984. constantAttenuation?: number;
  67985. linearAttenuation?: number;
  67986. quadraticAttenuation?: number;
  67987. }
  67988. /** @hidden */
  67989. export interface IGLTFSpotLight {
  67990. color?: number[];
  67991. constantAttenuation?: number;
  67992. fallOfAngle?: number;
  67993. fallOffExponent?: number;
  67994. linearAttenuation?: number;
  67995. quadraticAttenuation?: number;
  67996. }
  67997. /** @hidden */
  67998. export interface IGLTFLight extends IGLTFChildRootProperty {
  67999. type: string;
  68000. }
  68001. /** @hidden */
  68002. export interface IGLTFCameraOrthographic {
  68003. xmag: number;
  68004. ymag: number;
  68005. zfar: number;
  68006. znear: number;
  68007. }
  68008. /** @hidden */
  68009. export interface IGLTFCameraPerspective {
  68010. aspectRatio: number;
  68011. yfov: number;
  68012. zfar: number;
  68013. znear: number;
  68014. }
  68015. /** @hidden */
  68016. export interface IGLTFCamera extends IGLTFChildRootProperty {
  68017. type: string;
  68018. }
  68019. /** @hidden */
  68020. export interface IGLTFAnimationChannelTarget {
  68021. id: string;
  68022. path: string;
  68023. }
  68024. /** @hidden */
  68025. export interface IGLTFAnimationChannel {
  68026. sampler: string;
  68027. target: IGLTFAnimationChannelTarget;
  68028. }
  68029. /** @hidden */
  68030. export interface IGLTFAnimationSampler {
  68031. input: string;
  68032. output: string;
  68033. interpolation?: string;
  68034. }
  68035. /** @hidden */
  68036. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  68037. channels?: IGLTFAnimationChannel[];
  68038. parameters?: {
  68039. [key: string]: string;
  68040. };
  68041. samplers?: {
  68042. [key: string]: IGLTFAnimationSampler;
  68043. };
  68044. }
  68045. /** @hidden */
  68046. export interface IGLTFNodeInstanceSkin {
  68047. skeletons: string[];
  68048. skin: string;
  68049. meshes: string[];
  68050. }
  68051. /** @hidden */
  68052. export interface IGLTFSkins extends IGLTFChildRootProperty {
  68053. bindShapeMatrix: number[];
  68054. inverseBindMatrices: string;
  68055. jointNames: string[];
  68056. babylonSkeleton?: Skeleton;
  68057. }
  68058. /** @hidden */
  68059. export interface IGLTFNode extends IGLTFChildRootProperty {
  68060. camera?: string;
  68061. children: string[];
  68062. skin?: string;
  68063. jointName?: string;
  68064. light?: string;
  68065. matrix: number[];
  68066. mesh?: string;
  68067. meshes?: string[];
  68068. rotation?: number[];
  68069. scale?: number[];
  68070. translation?: number[];
  68071. babylonNode?: Node;
  68072. }
  68073. /** @hidden */
  68074. export interface IGLTFScene extends IGLTFChildRootProperty {
  68075. nodes: string[];
  68076. }
  68077. /** @hidden */
  68078. export interface IGLTFRuntime {
  68079. extensions: {
  68080. [key: string]: any;
  68081. };
  68082. accessors: {
  68083. [key: string]: IGLTFAccessor;
  68084. };
  68085. buffers: {
  68086. [key: string]: IGLTFBuffer;
  68087. };
  68088. bufferViews: {
  68089. [key: string]: IGLTFBufferView;
  68090. };
  68091. meshes: {
  68092. [key: string]: IGLTFMesh;
  68093. };
  68094. lights: {
  68095. [key: string]: IGLTFLight;
  68096. };
  68097. cameras: {
  68098. [key: string]: IGLTFCamera;
  68099. };
  68100. nodes: {
  68101. [key: string]: IGLTFNode;
  68102. };
  68103. images: {
  68104. [key: string]: IGLTFImage;
  68105. };
  68106. textures: {
  68107. [key: string]: IGLTFTexture;
  68108. };
  68109. shaders: {
  68110. [key: string]: IGLTFShader;
  68111. };
  68112. programs: {
  68113. [key: string]: IGLTFProgram;
  68114. };
  68115. samplers: {
  68116. [key: string]: IGLTFSampler;
  68117. };
  68118. techniques: {
  68119. [key: string]: IGLTFTechnique;
  68120. };
  68121. materials: {
  68122. [key: string]: IGLTFMaterial;
  68123. };
  68124. animations: {
  68125. [key: string]: IGLTFAnimation;
  68126. };
  68127. skins: {
  68128. [key: string]: IGLTFSkins;
  68129. };
  68130. currentScene?: Object;
  68131. scenes: {
  68132. [key: string]: IGLTFScene;
  68133. };
  68134. extensionsUsed: string[];
  68135. extensionsRequired?: string[];
  68136. buffersCount: number;
  68137. shaderscount: number;
  68138. scene: Scene;
  68139. rootUrl: string;
  68140. loadedBufferCount: number;
  68141. loadedBufferViews: {
  68142. [name: string]: ArrayBufferView;
  68143. };
  68144. loadedShaderCount: number;
  68145. importOnlyMeshes: boolean;
  68146. importMeshesNames?: string[];
  68147. dummyNodes: Node[];
  68148. }
  68149. /** @hidden */
  68150. export interface INodeToRoot {
  68151. bone: Bone;
  68152. node: IGLTFNode;
  68153. id: string;
  68154. }
  68155. /** @hidden */
  68156. export interface IJointNode {
  68157. node: IGLTFNode;
  68158. id: string;
  68159. }
  68160. }
  68161. declare module BABYLON.GLTF1 {
  68162. /**
  68163. * Utils functions for GLTF
  68164. * @hidden
  68165. */
  68166. export class GLTFUtils {
  68167. /**
  68168. * Sets the given "parameter" matrix
  68169. * @param scene: the Scene object
  68170. * @param source: the source node where to pick the matrix
  68171. * @param parameter: the GLTF technique parameter
  68172. * @param uniformName: the name of the shader's uniform
  68173. * @param shaderMaterial: the shader material
  68174. */
  68175. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  68176. /**
  68177. * Sets the given "parameter" matrix
  68178. * @param shaderMaterial: the shader material
  68179. * @param uniform: the name of the shader's uniform
  68180. * @param value: the value of the uniform
  68181. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  68182. */
  68183. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  68184. /**
  68185. * Returns the wrap mode of the texture
  68186. * @param mode: the mode value
  68187. */
  68188. static GetWrapMode(mode: number): number;
  68189. /**
  68190. * Returns the byte stride giving an accessor
  68191. * @param accessor: the GLTF accessor objet
  68192. */
  68193. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  68194. /**
  68195. * Returns the texture filter mode giving a mode value
  68196. * @param mode: the filter mode value
  68197. */
  68198. static GetTextureFilterMode(mode: number): ETextureFilterType;
  68199. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  68200. /**
  68201. * Returns a buffer from its accessor
  68202. * @param gltfRuntime: the GLTF runtime
  68203. * @param accessor: the GLTF accessor
  68204. */
  68205. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  68206. /**
  68207. * Decodes a buffer view into a string
  68208. * @param view: the buffer view
  68209. */
  68210. static DecodeBufferToText(view: ArrayBufferView): string;
  68211. /**
  68212. * Returns the default material of gltf. Related to
  68213. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  68214. * @param scene: the Babylon.js scene
  68215. */
  68216. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  68217. private static _DefaultMaterial;
  68218. }
  68219. }
  68220. declare module BABYLON.GLTF1 {
  68221. /**
  68222. * Implementation of the base glTF spec
  68223. * @hidden
  68224. */
  68225. export class GLTFLoaderBase {
  68226. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  68227. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  68228. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  68229. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  68230. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  68231. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  68232. }
  68233. /**
  68234. * glTF V1 Loader
  68235. * @hidden
  68236. */
  68237. export class GLTFLoader implements IGLTFLoader {
  68238. static Extensions: {
  68239. [name: string]: GLTFLoaderExtension;
  68240. };
  68241. static RegisterExtension(extension: GLTFLoaderExtension): void;
  68242. state: Nullable<GLTFLoaderState>;
  68243. dispose(): void;
  68244. private _importMeshAsync;
  68245. /**
  68246. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  68247. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68248. * @param scene the scene the meshes should be added to
  68249. * @param data gltf data containing information of the meshes in a loaded file
  68250. * @param rootUrl root url to load from
  68251. * @param onProgress event that fires when loading progress has occured
  68252. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68253. */
  68254. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  68255. meshes: AbstractMesh[];
  68256. particleSystems: IParticleSystem[];
  68257. skeletons: Skeleton[];
  68258. animationGroups: AnimationGroup[];
  68259. }>;
  68260. private _loadAsync;
  68261. /**
  68262. * Imports all objects from a loaded gltf file and adds them to the scene
  68263. * @param scene the scene the objects should be added to
  68264. * @param data gltf data containing information of the meshes in a loaded file
  68265. * @param rootUrl root url to load from
  68266. * @param onProgress event that fires when loading progress has occured
  68267. * @returns a promise which completes when objects have been loaded to the scene
  68268. */
  68269. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  68270. private _loadShadersAsync;
  68271. private _loadBuffersAsync;
  68272. private _createNodes;
  68273. }
  68274. /** @hidden */
  68275. export abstract class GLTFLoaderExtension {
  68276. private _name;
  68277. constructor(name: string);
  68278. readonly name: string;
  68279. /**
  68280. * Defines an override for loading the runtime
  68281. * Return true to stop further extensions from loading the runtime
  68282. */
  68283. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  68284. /**
  68285. * Defines an onverride for creating gltf runtime
  68286. * Return true to stop further extensions from creating the runtime
  68287. */
  68288. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  68289. /**
  68290. * Defines an override for loading buffers
  68291. * Return true to stop further extensions from loading this buffer
  68292. */
  68293. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  68294. /**
  68295. * Defines an override for loading texture buffers
  68296. * Return true to stop further extensions from loading this texture data
  68297. */
  68298. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68299. /**
  68300. * Defines an override for creating textures
  68301. * Return true to stop further extensions from loading this texture
  68302. */
  68303. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  68304. /**
  68305. * Defines an override for loading shader strings
  68306. * Return true to stop further extensions from loading this shader data
  68307. */
  68308. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  68309. /**
  68310. * Defines an override for loading materials
  68311. * Return true to stop further extensions from loading this material
  68312. */
  68313. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  68314. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  68315. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  68316. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  68317. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  68318. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  68319. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  68320. private static LoadTextureBufferAsync;
  68321. private static CreateTextureAsync;
  68322. private static ApplyExtensions;
  68323. }
  68324. }
  68325. declare module BABYLON.GLTF1 {
  68326. /** @hidden */
  68327. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  68328. private _bin;
  68329. constructor();
  68330. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  68331. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68332. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68333. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  68334. }
  68335. }
  68336. declare module BABYLON.GLTF1 {
  68337. /** @hidden */
  68338. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  68339. constructor();
  68340. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  68341. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  68342. private _loadTexture;
  68343. }
  68344. }
  68345. declare module BABYLON.GLTF2.Loader {
  68346. /**
  68347. * Loader interface with an index field.
  68348. */
  68349. export interface IArrayItem {
  68350. /**
  68351. * The index of this item in the array.
  68352. */
  68353. index: number;
  68354. }
  68355. /**
  68356. * Loader interface with additional members.
  68357. */
  68358. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  68359. /** @hidden */
  68360. _data?: Promise<ArrayBufferView>;
  68361. /** @hidden */
  68362. _babylonVertexBuffer?: Promise<VertexBuffer>;
  68363. }
  68364. /**
  68365. * Loader interface with additional members.
  68366. */
  68367. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  68368. }
  68369. /** @hidden */
  68370. export interface _IAnimationSamplerData {
  68371. input: Float32Array;
  68372. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  68373. output: Float32Array;
  68374. }
  68375. /**
  68376. * Loader interface with additional members.
  68377. */
  68378. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  68379. /** @hidden */
  68380. _data?: Promise<_IAnimationSamplerData>;
  68381. }
  68382. /**
  68383. * Loader interface with additional members.
  68384. */
  68385. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  68386. channels: IAnimationChannel[];
  68387. samplers: IAnimationSampler[];
  68388. /** @hidden */
  68389. _babylonAnimationGroup?: AnimationGroup;
  68390. }
  68391. /**
  68392. * Loader interface with additional members.
  68393. */
  68394. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  68395. /** @hidden */
  68396. _data?: Promise<ArrayBufferView>;
  68397. }
  68398. /**
  68399. * Loader interface with additional members.
  68400. */
  68401. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  68402. /** @hidden */
  68403. _data?: Promise<ArrayBufferView>;
  68404. /** @hidden */
  68405. _babylonBuffer?: Promise<Buffer>;
  68406. }
  68407. /**
  68408. * Loader interface with additional members.
  68409. */
  68410. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  68411. }
  68412. /**
  68413. * Loader interface with additional members.
  68414. */
  68415. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  68416. /** @hidden */
  68417. _data?: Promise<ArrayBufferView>;
  68418. }
  68419. /**
  68420. * Loader interface with additional members.
  68421. */
  68422. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  68423. }
  68424. /**
  68425. * Loader interface with additional members.
  68426. */
  68427. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  68428. }
  68429. /**
  68430. * Loader interface with additional members.
  68431. */
  68432. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  68433. baseColorTexture?: ITextureInfo;
  68434. metallicRoughnessTexture?: ITextureInfo;
  68435. }
  68436. /**
  68437. * Loader interface with additional members.
  68438. */
  68439. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  68440. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68441. normalTexture?: IMaterialNormalTextureInfo;
  68442. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68443. emissiveTexture?: ITextureInfo;
  68444. /** @hidden */
  68445. _data?: {
  68446. [babylonDrawMode: number]: {
  68447. babylonMaterial: Material;
  68448. babylonMeshes: AbstractMesh[];
  68449. promise: Promise<void>;
  68450. };
  68451. };
  68452. }
  68453. /**
  68454. * Loader interface with additional members.
  68455. */
  68456. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  68457. primitives: IMeshPrimitive[];
  68458. }
  68459. /**
  68460. * Loader interface with additional members.
  68461. */
  68462. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  68463. /** @hidden */
  68464. _instanceData?: {
  68465. babylonSourceMesh: Mesh;
  68466. promise: Promise<any>;
  68467. };
  68468. }
  68469. /**
  68470. * Loader interface with additional members.
  68471. */
  68472. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  68473. /**
  68474. * The parent glTF node.
  68475. */
  68476. parent?: INode;
  68477. /** @hidden */
  68478. _babylonTransformNode?: TransformNode;
  68479. /** @hidden */
  68480. _primitiveBabylonMeshes?: AbstractMesh[];
  68481. /** @hidden */
  68482. _babylonBones?: Bone[];
  68483. /** @hidden */
  68484. _numMorphTargets?: number;
  68485. }
  68486. /** @hidden */
  68487. export interface _ISamplerData {
  68488. noMipMaps: boolean;
  68489. samplingMode: number;
  68490. wrapU: number;
  68491. wrapV: number;
  68492. }
  68493. /**
  68494. * Loader interface with additional members.
  68495. */
  68496. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  68497. /** @hidden */
  68498. _data?: _ISamplerData;
  68499. }
  68500. /**
  68501. * Loader interface with additional members.
  68502. */
  68503. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  68504. }
  68505. /**
  68506. * Loader interface with additional members.
  68507. */
  68508. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  68509. /** @hidden */
  68510. _data?: {
  68511. babylonSkeleton: Skeleton;
  68512. promise: Promise<void>;
  68513. };
  68514. }
  68515. /**
  68516. * Loader interface with additional members.
  68517. */
  68518. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  68519. }
  68520. /**
  68521. * Loader interface with additional members.
  68522. */
  68523. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  68524. }
  68525. /**
  68526. * Loader interface with additional members.
  68527. */
  68528. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  68529. accessors?: IAccessor[];
  68530. animations?: IAnimation[];
  68531. buffers?: IBuffer[];
  68532. bufferViews?: IBufferView[];
  68533. cameras?: ICamera[];
  68534. images?: IImage[];
  68535. materials?: IMaterial[];
  68536. meshes?: IMesh[];
  68537. nodes?: INode[];
  68538. samplers?: ISampler[];
  68539. scenes?: IScene[];
  68540. skins?: ISkin[];
  68541. textures?: ITexture[];
  68542. }
  68543. }
  68544. declare module BABYLON.GLTF2 {
  68545. /**
  68546. * Interface for a glTF loader extension.
  68547. */
  68548. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  68549. /**
  68550. * Called after the loader state changes to LOADING.
  68551. */
  68552. onLoading?(): void;
  68553. /**
  68554. * Called after the loader state changes to READY.
  68555. */
  68556. onReady?(): void;
  68557. /**
  68558. * Define this method to modify the default behavior when loading scenes.
  68559. * @param context The context when loading the asset
  68560. * @param scene The glTF scene property
  68561. * @returns A promise that resolves when the load is complete or null if not handled
  68562. */
  68563. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  68564. /**
  68565. * Define this method to modify the default behavior when loading nodes.
  68566. * @param context The context when loading the asset
  68567. * @param node The glTF node property
  68568. * @param assign A function called synchronously after parsing the glTF properties
  68569. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  68570. */
  68571. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68572. /**
  68573. * Define this method to modify the default behavior when loading cameras.
  68574. * @param context The context when loading the asset
  68575. * @param camera The glTF camera property
  68576. * @param assign A function called synchronously after parsing the glTF properties
  68577. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  68578. */
  68579. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68580. /**
  68581. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  68582. * @param context The context when loading the asset
  68583. * @param primitive The glTF mesh primitive property
  68584. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  68585. */
  68586. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68587. /**
  68588. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68589. * @param context The context when loading the asset
  68590. * @param name The mesh name when loading the asset
  68591. * @param node The glTF node when loading the asset
  68592. * @param mesh The glTF mesh when loading the asset
  68593. * @param primitive The glTF mesh primitive property
  68594. * @param assign A function called synchronously after parsing the glTF properties
  68595. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68596. */
  68597. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68598. /**
  68599. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  68600. * @param context The context when loading the asset
  68601. * @param material The glTF material property
  68602. * @param assign A function called synchronously after parsing the glTF properties
  68603. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  68604. */
  68605. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68606. /**
  68607. * Define this method to modify the default behavior when creating materials.
  68608. * @param context The context when loading the asset
  68609. * @param material The glTF material property
  68610. * @param babylonDrawMode The draw mode for the Babylon material
  68611. * @returns The Babylon material or null if not handled
  68612. */
  68613. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68614. /**
  68615. * Define this method to modify the default behavior when loading material properties.
  68616. * @param context The context when loading the asset
  68617. * @param material The glTF material property
  68618. * @param babylonMaterial The Babylon material
  68619. * @returns A promise that resolves when the load is complete or null if not handled
  68620. */
  68621. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68622. /**
  68623. * Define this method to modify the default behavior when loading texture infos.
  68624. * @param context The context when loading the asset
  68625. * @param textureInfo The glTF texture info property
  68626. * @param assign A function called synchronously after parsing the glTF properties
  68627. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  68628. */
  68629. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68630. /**
  68631. * Define this method to modify the default behavior when loading animations.
  68632. * @param context The context when loading the asset
  68633. * @param animation The glTF animation property
  68634. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  68635. */
  68636. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68637. /**
  68638. * @hidden Define this method to modify the default behavior when loading skins.
  68639. * @param context The context when loading the asset
  68640. * @param node The glTF node property
  68641. * @param skin The glTF skin property
  68642. * @returns A promise that resolves when the load is complete or null if not handled
  68643. */
  68644. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  68645. /**
  68646. * @hidden Define this method to modify the default behavior when loading uris.
  68647. * @param context The context when loading the asset
  68648. * @param property The glTF property associated with the uri
  68649. * @param uri The uri to load
  68650. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  68651. */
  68652. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68653. }
  68654. }
  68655. declare module BABYLON.GLTF2 {
  68656. /**
  68657. * Helper class for working with arrays when loading the glTF asset
  68658. */
  68659. export class ArrayItem {
  68660. /**
  68661. * Gets an item from the given array.
  68662. * @param context The context when loading the asset
  68663. * @param array The array to get the item from
  68664. * @param index The index to the array
  68665. * @returns The array item
  68666. */
  68667. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  68668. /**
  68669. * Assign an `index` field to each item of the given array.
  68670. * @param array The array of items
  68671. */
  68672. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  68673. }
  68674. /**
  68675. * The glTF 2.0 loader
  68676. */
  68677. export class GLTFLoader implements IGLTFLoader {
  68678. /** @hidden */
  68679. _completePromises: Promise<any>[];
  68680. private _disposed;
  68681. private _parent;
  68682. private _state;
  68683. private _extensions;
  68684. private _rootUrl;
  68685. private _fileName;
  68686. private _uniqueRootUrl;
  68687. private _gltf;
  68688. private _babylonScene;
  68689. private _rootBabylonMesh;
  68690. private _defaultBabylonMaterialData;
  68691. private _progressCallback?;
  68692. private _requests;
  68693. private static readonly _DefaultSampler;
  68694. private static _ExtensionNames;
  68695. private static _ExtensionFactories;
  68696. /**
  68697. * Registers a loader extension.
  68698. * @param name The name of the loader extension.
  68699. * @param factory The factory function that creates the loader extension.
  68700. */
  68701. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  68702. /**
  68703. * Unregisters a loader extension.
  68704. * @param name The name of the loader extenion.
  68705. * @returns A boolean indicating whether the extension has been unregistered
  68706. */
  68707. static UnregisterExtension(name: string): boolean;
  68708. /**
  68709. * Gets the loader state.
  68710. */
  68711. readonly state: Nullable<GLTFLoaderState>;
  68712. /**
  68713. * The glTF object parsed from the JSON.
  68714. */
  68715. readonly gltf: IGLTF;
  68716. /**
  68717. * The Babylon scene when loading the asset.
  68718. */
  68719. readonly babylonScene: Scene;
  68720. /**
  68721. * The root Babylon mesh when loading the asset.
  68722. */
  68723. readonly rootBabylonMesh: Mesh;
  68724. /** @hidden */
  68725. constructor(parent: GLTFFileLoader);
  68726. /** @hidden */
  68727. dispose(): void;
  68728. /** @hidden */
  68729. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68730. meshes: AbstractMesh[];
  68731. particleSystems: IParticleSystem[];
  68732. skeletons: Skeleton[];
  68733. animationGroups: AnimationGroup[];
  68734. }>;
  68735. /** @hidden */
  68736. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68737. private _loadAsync;
  68738. private _loadData;
  68739. private _setupData;
  68740. private _loadExtensions;
  68741. private _checkExtensions;
  68742. private _setState;
  68743. private _createRootNode;
  68744. /**
  68745. * Loads a glTF scene.
  68746. * @param context The context when loading the asset
  68747. * @param scene The glTF scene property
  68748. * @returns A promise that resolves when the load is complete
  68749. */
  68750. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  68751. private _forEachPrimitive;
  68752. private _getMeshes;
  68753. private _getSkeletons;
  68754. private _getAnimationGroups;
  68755. private _startAnimations;
  68756. /**
  68757. * Loads a glTF node.
  68758. * @param context The context when loading the asset
  68759. * @param node The glTF node property
  68760. * @param assign A function called synchronously after parsing the glTF properties
  68761. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  68762. */
  68763. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  68764. private _loadMeshAsync;
  68765. /**
  68766. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68767. * @param context The context when loading the asset
  68768. * @param name The mesh name when loading the asset
  68769. * @param node The glTF node when loading the asset
  68770. * @param mesh The glTF mesh when loading the asset
  68771. * @param primitive The glTF mesh primitive property
  68772. * @param assign A function called synchronously after parsing the glTF properties
  68773. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68774. */
  68775. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68776. private _loadVertexDataAsync;
  68777. private _createMorphTargets;
  68778. private _loadMorphTargetsAsync;
  68779. private _loadMorphTargetVertexDataAsync;
  68780. private static _LoadTransform;
  68781. private _loadSkinAsync;
  68782. private _loadBones;
  68783. private _loadBone;
  68784. private _loadSkinInverseBindMatricesDataAsync;
  68785. private _updateBoneMatrices;
  68786. private _getNodeMatrix;
  68787. /**
  68788. * Loads a glTF camera.
  68789. * @param context The context when loading the asset
  68790. * @param camera The glTF camera property
  68791. * @param assign A function called synchronously after parsing the glTF properties
  68792. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  68793. */
  68794. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  68795. private _loadAnimationsAsync;
  68796. /**
  68797. * Loads a glTF animation.
  68798. * @param context The context when loading the asset
  68799. * @param animation The glTF animation property
  68800. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  68801. */
  68802. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  68803. /**
  68804. * @hidden Loads a glTF animation channel.
  68805. * @param context The context when loading the asset
  68806. * @param animationContext The context of the animation when loading the asset
  68807. * @param animation The glTF animation property
  68808. * @param channel The glTF animation channel property
  68809. * @param babylonAnimationGroup The babylon animation group property
  68810. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  68811. * @returns A void promise when the channel load is complete
  68812. */
  68813. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  68814. private _loadAnimationSamplerAsync;
  68815. private _loadBufferAsync;
  68816. /**
  68817. * Loads a glTF buffer view.
  68818. * @param context The context when loading the asset
  68819. * @param bufferView The glTF buffer view property
  68820. * @returns A promise that resolves with the loaded data when the load is complete
  68821. */
  68822. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  68823. private _loadAccessorAsync;
  68824. private _loadFloatAccessorAsync;
  68825. private _loadIndicesAccessorAsync;
  68826. private _loadVertexBufferViewAsync;
  68827. private _loadVertexAccessorAsync;
  68828. private _loadMaterialMetallicRoughnessPropertiesAsync;
  68829. /** @hidden */
  68830. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  68831. private _createDefaultMaterial;
  68832. /**
  68833. * Creates a Babylon material from a glTF material.
  68834. * @param context The context when loading the asset
  68835. * @param material The glTF material property
  68836. * @param babylonDrawMode The draw mode for the Babylon material
  68837. * @returns The Babylon material
  68838. */
  68839. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  68840. /**
  68841. * Loads properties from a glTF material into a Babylon material.
  68842. * @param context The context when loading the asset
  68843. * @param material The glTF material property
  68844. * @param babylonMaterial The Babylon material
  68845. * @returns A promise that resolves when the load is complete
  68846. */
  68847. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68848. /**
  68849. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  68850. * @param context The context when loading the asset
  68851. * @param material The glTF material property
  68852. * @param babylonMaterial The Babylon material
  68853. * @returns A promise that resolves when the load is complete
  68854. */
  68855. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68856. /**
  68857. * Loads the alpha properties from a glTF material into a Babylon material.
  68858. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  68859. * @param context The context when loading the asset
  68860. * @param material The glTF material property
  68861. * @param babylonMaterial The Babylon material
  68862. */
  68863. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  68864. /**
  68865. * Loads a glTF texture info.
  68866. * @param context The context when loading the asset
  68867. * @param textureInfo The glTF texture info property
  68868. * @param assign A function called synchronously after parsing the glTF properties
  68869. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  68870. */
  68871. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  68872. private _loadTextureAsync;
  68873. private _loadSampler;
  68874. /**
  68875. * Loads a glTF image.
  68876. * @param context The context when loading the asset
  68877. * @param image The glTF image property
  68878. * @returns A promise that resolves with the loaded data when the load is complete
  68879. */
  68880. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  68881. /**
  68882. * Loads a glTF uri.
  68883. * @param context The context when loading the asset
  68884. * @param property The glTF property associated with the uri
  68885. * @param uri The base64 or relative uri
  68886. * @returns A promise that resolves with the loaded data when the load is complete
  68887. */
  68888. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  68889. private _onProgress;
  68890. /**
  68891. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  68892. * @param babylonObject the Babylon object with metadata
  68893. * @param pointer the JSON pointer
  68894. */
  68895. static AddPointerMetadata(babylonObject: {
  68896. metadata: any;
  68897. }, pointer: string): void;
  68898. private static _GetTextureWrapMode;
  68899. private static _GetTextureSamplingMode;
  68900. private static _GetTypedArrayConstructor;
  68901. private static _GetTypedArray;
  68902. private static _GetNumComponents;
  68903. private static _ValidateUri;
  68904. private static _GetDrawMode;
  68905. private _compileMaterialsAsync;
  68906. private _compileShadowGeneratorsAsync;
  68907. private _forEachExtensions;
  68908. private _applyExtensions;
  68909. private _extensionsOnLoading;
  68910. private _extensionsOnReady;
  68911. private _extensionsLoadSceneAsync;
  68912. private _extensionsLoadNodeAsync;
  68913. private _extensionsLoadCameraAsync;
  68914. private _extensionsLoadVertexDataAsync;
  68915. private _extensionsLoadMeshPrimitiveAsync;
  68916. private _extensionsLoadMaterialAsync;
  68917. private _extensionsCreateMaterial;
  68918. private _extensionsLoadMaterialPropertiesAsync;
  68919. private _extensionsLoadTextureInfoAsync;
  68920. private _extensionsLoadAnimationAsync;
  68921. private _extensionsLoadSkinAsync;
  68922. private _extensionsLoadUriAsync;
  68923. /**
  68924. * Helper method called by a loader extension to load an glTF extension.
  68925. * @param context The context when loading the asset
  68926. * @param property The glTF property to load the extension from
  68927. * @param extensionName The name of the extension to load
  68928. * @param actionAsync The action to run
  68929. * @returns The promise returned by actionAsync or null if the extension does not exist
  68930. */
  68931. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68932. /**
  68933. * Helper method called by a loader extension to load a glTF extra.
  68934. * @param context The context when loading the asset
  68935. * @param property The glTF property to load the extra from
  68936. * @param extensionName The name of the extension to load
  68937. * @param actionAsync The action to run
  68938. * @returns The promise returned by actionAsync or null if the extra does not exist
  68939. */
  68940. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68941. /**
  68942. * Increments the indentation level and logs a message.
  68943. * @param message The message to log
  68944. */
  68945. logOpen(message: string): void;
  68946. /**
  68947. * Decrements the indentation level.
  68948. */
  68949. logClose(): void;
  68950. /**
  68951. * Logs a message
  68952. * @param message The message to log
  68953. */
  68954. log(message: string): void;
  68955. /**
  68956. * Starts a performance counter.
  68957. * @param counterName The name of the performance counter
  68958. */
  68959. startPerformanceCounter(counterName: string): void;
  68960. /**
  68961. * Ends a performance counter.
  68962. * @param counterName The name of the performance counter
  68963. */
  68964. endPerformanceCounter(counterName: string): void;
  68965. }
  68966. }
  68967. declare module BABYLON.GLTF2.Loader.Extensions {
  68968. /**
  68969. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  68970. */
  68971. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  68972. /** The name of this extension. */
  68973. readonly name: string;
  68974. /** Defines whether this extension is enabled. */
  68975. enabled: boolean;
  68976. private _loader;
  68977. private _lights?;
  68978. /** @hidden */
  68979. constructor(loader: GLTFLoader);
  68980. /** @hidden */
  68981. dispose(): void;
  68982. /** @hidden */
  68983. onLoading(): void;
  68984. /** @hidden */
  68985. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68986. private _loadLightAsync;
  68987. }
  68988. }
  68989. declare module BABYLON.GLTF2.Loader.Extensions {
  68990. /**
  68991. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  68992. */
  68993. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  68994. /** The name of this extension. */
  68995. readonly name: string;
  68996. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  68997. dracoCompression?: DracoCompression;
  68998. /** Defines whether this extension is enabled. */
  68999. enabled: boolean;
  69000. private _loader;
  69001. /** @hidden */
  69002. constructor(loader: GLTFLoader);
  69003. /** @hidden */
  69004. dispose(): void;
  69005. /** @hidden */
  69006. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  69007. }
  69008. }
  69009. declare module BABYLON.GLTF2.Loader.Extensions {
  69010. /**
  69011. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  69012. */
  69013. export class KHR_lights implements IGLTFLoaderExtension {
  69014. /** The name of this extension. */
  69015. readonly name: string;
  69016. /** Defines whether this extension is enabled. */
  69017. enabled: boolean;
  69018. private _loader;
  69019. private _lights?;
  69020. /** @hidden */
  69021. constructor(loader: GLTFLoader);
  69022. /** @hidden */
  69023. dispose(): void;
  69024. /** @hidden */
  69025. onLoading(): void;
  69026. /** @hidden */
  69027. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69028. }
  69029. }
  69030. declare module BABYLON.GLTF2.Loader.Extensions {
  69031. /**
  69032. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  69033. */
  69034. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  69035. /** The name of this extension. */
  69036. readonly name: string;
  69037. /** Defines whether this extension is enabled. */
  69038. enabled: boolean;
  69039. private _loader;
  69040. /** @hidden */
  69041. constructor(loader: GLTFLoader);
  69042. /** @hidden */
  69043. dispose(): void;
  69044. /** @hidden */
  69045. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69046. private _loadSpecularGlossinessPropertiesAsync;
  69047. }
  69048. }
  69049. declare module BABYLON.GLTF2.Loader.Extensions {
  69050. /**
  69051. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  69052. */
  69053. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  69054. /** The name of this extension. */
  69055. readonly name: string;
  69056. /** Defines whether this extension is enabled. */
  69057. enabled: boolean;
  69058. private _loader;
  69059. /** @hidden */
  69060. constructor(loader: GLTFLoader);
  69061. /** @hidden */
  69062. dispose(): void;
  69063. /** @hidden */
  69064. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69065. private _loadUnlitPropertiesAsync;
  69066. }
  69067. }
  69068. declare module BABYLON.GLTF2.Loader.Extensions {
  69069. /**
  69070. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  69071. */
  69072. export class KHR_texture_transform implements IGLTFLoaderExtension {
  69073. /** The name of this extension. */
  69074. readonly name: string;
  69075. /** Defines whether this extension is enabled. */
  69076. enabled: boolean;
  69077. private _loader;
  69078. /** @hidden */
  69079. constructor(loader: GLTFLoader);
  69080. /** @hidden */
  69081. dispose(): void;
  69082. /** @hidden */
  69083. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  69084. }
  69085. }
  69086. declare module BABYLON.GLTF2.Loader.Extensions {
  69087. /**
  69088. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  69089. */
  69090. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  69091. /** The name of this extension. */
  69092. readonly name: string;
  69093. /** Defines whether this extension is enabled. */
  69094. enabled: boolean;
  69095. private _loader;
  69096. private _clips;
  69097. private _emitters;
  69098. /** @hidden */
  69099. constructor(loader: GLTFLoader);
  69100. /** @hidden */
  69101. dispose(): void;
  69102. /** @hidden */
  69103. onLoading(): void;
  69104. /** @hidden */
  69105. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  69106. /** @hidden */
  69107. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69108. /** @hidden */
  69109. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  69110. private _loadClipAsync;
  69111. private _loadEmitterAsync;
  69112. private _getEventAction;
  69113. private _loadAnimationEventAsync;
  69114. }
  69115. }
  69116. declare module BABYLON.GLTF2.Loader.Extensions {
  69117. /**
  69118. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  69119. */
  69120. export class MSFT_lod implements IGLTFLoaderExtension {
  69121. /** The name of this extension. */
  69122. readonly name: string;
  69123. /** Defines whether this extension is enabled. */
  69124. enabled: boolean;
  69125. /**
  69126. * Maximum number of LODs to load, starting from the lowest LOD.
  69127. */
  69128. maxLODsToLoad: number;
  69129. /**
  69130. * Observable raised when all node LODs of one level are loaded.
  69131. * The event data is the index of the loaded LOD starting from zero.
  69132. * Dispose the loader to cancel the loading of the next level of LODs.
  69133. */
  69134. onNodeLODsLoadedObservable: Observable<number>;
  69135. /**
  69136. * Observable raised when all material LODs of one level are loaded.
  69137. * The event data is the index of the loaded LOD starting from zero.
  69138. * Dispose the loader to cancel the loading of the next level of LODs.
  69139. */
  69140. onMaterialLODsLoadedObservable: Observable<number>;
  69141. private _loader;
  69142. private _nodeIndexLOD;
  69143. private _nodeSignalLODs;
  69144. private _nodePromiseLODs;
  69145. private _materialIndexLOD;
  69146. private _materialSignalLODs;
  69147. private _materialPromiseLODs;
  69148. /** @hidden */
  69149. constructor(loader: GLTFLoader);
  69150. /** @hidden */
  69151. dispose(): void;
  69152. /** @hidden */
  69153. onReady(): void;
  69154. /** @hidden */
  69155. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69156. /** @hidden */
  69157. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  69158. /** @hidden */
  69159. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  69160. /**
  69161. * Gets an array of LOD properties from lowest to highest.
  69162. */
  69163. private _getLODs;
  69164. private _disposeUnusedMaterials;
  69165. }
  69166. }
  69167. declare module BABYLON.GLTF2.Loader.Extensions {
  69168. /** @hidden */
  69169. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  69170. readonly name: string;
  69171. enabled: boolean;
  69172. private _loader;
  69173. constructor(loader: GLTFLoader);
  69174. dispose(): void;
  69175. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69176. }
  69177. }
  69178. declare module BABYLON.GLTF2.Loader.Extensions {
  69179. /** @hidden */
  69180. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  69181. readonly name: string;
  69182. enabled: boolean;
  69183. private _loader;
  69184. constructor(loader: GLTFLoader);
  69185. dispose(): void;
  69186. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69187. }
  69188. }
  69189. declare module BABYLON.GLTF2.Loader.Extensions {
  69190. /**
  69191. * Store glTF extras (if present) in BJS objects' metadata
  69192. */
  69193. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  69194. /** The name of this extension. */
  69195. readonly name: string;
  69196. /** Defines whether this extension is enabled. */
  69197. enabled: boolean;
  69198. private _loader;
  69199. private _assignExtras;
  69200. /** @hidden */
  69201. constructor(loader: GLTFLoader);
  69202. /** @hidden */
  69203. dispose(): void;
  69204. /** @hidden */
  69205. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69206. /** @hidden */
  69207. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69208. /** @hidden */
  69209. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69210. }
  69211. }
  69212. declare module BABYLON {
  69213. /**
  69214. * Class reading and parsing the MTL file bundled with the obj file.
  69215. */
  69216. export class MTLFileLoader {
  69217. /**
  69218. * All material loaded from the mtl will be set here
  69219. */
  69220. materials: StandardMaterial[];
  69221. /**
  69222. * This function will read the mtl file and create each material described inside
  69223. * This function could be improve by adding :
  69224. * -some component missing (Ni, Tf...)
  69225. * -including the specific options available
  69226. *
  69227. * @param scene defines the scene the material will be created in
  69228. * @param data defines the mtl data to parse
  69229. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  69230. */
  69231. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  69232. /**
  69233. * Gets the texture for the material.
  69234. *
  69235. * If the material is imported from input file,
  69236. * We sanitize the url to ensure it takes the textre from aside the material.
  69237. *
  69238. * @param rootUrl The root url to load from
  69239. * @param value The value stored in the mtl
  69240. * @return The Texture
  69241. */
  69242. private static _getTexture;
  69243. }
  69244. /**
  69245. * Options for loading OBJ/MTL files
  69246. */
  69247. type MeshLoadOptions = {
  69248. /**
  69249. * Defines if UVs are optimized by default during load.
  69250. */
  69251. OptimizeWithUV: boolean;
  69252. /**
  69253. * Defines custom scaling of UV coordinates of loaded meshes.
  69254. */
  69255. UVScaling: Vector2;
  69256. /**
  69257. * Invert model on y-axis (does a model scaling inversion)
  69258. */
  69259. InvertY: boolean;
  69260. /**
  69261. * Invert Y-Axis of referenced textures on load
  69262. */
  69263. InvertTextureY: boolean;
  69264. /**
  69265. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  69266. */
  69267. ImportVertexColors: boolean;
  69268. /**
  69269. * Compute the normals for the model, even if normals are present in the file.
  69270. */
  69271. ComputeNormals: boolean;
  69272. /**
  69273. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  69274. */
  69275. SkipMaterials: boolean;
  69276. /**
  69277. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  69278. */
  69279. MaterialLoadingFailsSilently: boolean;
  69280. };
  69281. /**
  69282. * OBJ file type loader.
  69283. * This is a babylon scene loader plugin.
  69284. */
  69285. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  69286. /**
  69287. * Defines if UVs are optimized by default during load.
  69288. */
  69289. static OPTIMIZE_WITH_UV: boolean;
  69290. /**
  69291. * Invert model on y-axis (does a model scaling inversion)
  69292. */
  69293. static INVERT_Y: boolean;
  69294. /**
  69295. * Invert Y-Axis of referenced textures on load
  69296. */
  69297. static INVERT_TEXTURE_Y: boolean;
  69298. /**
  69299. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  69300. */
  69301. static IMPORT_VERTEX_COLORS: boolean;
  69302. /**
  69303. * Compute the normals for the model, even if normals are present in the file.
  69304. */
  69305. static COMPUTE_NORMALS: boolean;
  69306. /**
  69307. * Defines custom scaling of UV coordinates of loaded meshes.
  69308. */
  69309. static UV_SCALING: Vector2;
  69310. /**
  69311. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  69312. */
  69313. static SKIP_MATERIALS: boolean;
  69314. /**
  69315. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  69316. *
  69317. * Defaults to true for backwards compatibility.
  69318. */
  69319. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  69320. /**
  69321. * Defines the name of the plugin.
  69322. */
  69323. name: string;
  69324. /**
  69325. * Defines the extension the plugin is able to load.
  69326. */
  69327. extensions: string;
  69328. /** @hidden */
  69329. obj: RegExp;
  69330. /** @hidden */
  69331. group: RegExp;
  69332. /** @hidden */
  69333. mtllib: RegExp;
  69334. /** @hidden */
  69335. usemtl: RegExp;
  69336. /** @hidden */
  69337. smooth: RegExp;
  69338. /** @hidden */
  69339. vertexPattern: RegExp;
  69340. /** @hidden */
  69341. normalPattern: RegExp;
  69342. /** @hidden */
  69343. uvPattern: RegExp;
  69344. /** @hidden */
  69345. facePattern1: RegExp;
  69346. /** @hidden */
  69347. facePattern2: RegExp;
  69348. /** @hidden */
  69349. facePattern3: RegExp;
  69350. /** @hidden */
  69351. facePattern4: RegExp;
  69352. /** @hidden */
  69353. facePattern5: RegExp;
  69354. private _meshLoadOptions;
  69355. /**
  69356. * Creates loader for .OBJ files
  69357. *
  69358. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  69359. */
  69360. constructor(meshLoadOptions?: MeshLoadOptions);
  69361. private static readonly currentMeshLoadOptions;
  69362. /**
  69363. * Calls synchronously the MTL file attached to this obj.
  69364. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  69365. * Without this function materials are not displayed in the first frame (but displayed after).
  69366. * In consequence it is impossible to get material information in your HTML file
  69367. *
  69368. * @param url The URL of the MTL file
  69369. * @param rootUrl
  69370. * @param onSuccess Callback function to be called when the MTL file is loaded
  69371. * @private
  69372. */
  69373. private _loadMTL;
  69374. /**
  69375. * Instantiates a OBJ file loader plugin.
  69376. * @returns the created plugin
  69377. */
  69378. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  69379. /**
  69380. * If the data string can be loaded directly.
  69381. *
  69382. * @param data string containing the file data
  69383. * @returns if the data can be loaded directly
  69384. */
  69385. canDirectLoad(data: string): boolean;
  69386. /**
  69387. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  69388. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  69389. * @param scene the scene the meshes should be added to
  69390. * @param data the OBJ data to load
  69391. * @param rootUrl root url to load from
  69392. * @param onProgress event that fires when loading progress has occured
  69393. * @param fileName Defines the name of the file to load
  69394. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  69395. */
  69396. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69397. meshes: AbstractMesh[];
  69398. particleSystems: IParticleSystem[];
  69399. skeletons: Skeleton[];
  69400. animationGroups: AnimationGroup[];
  69401. }>;
  69402. /**
  69403. * Imports all objects from the loaded OBJ data and adds them to the scene
  69404. * @param scene the scene the objects should be added to
  69405. * @param data the OBJ data to load
  69406. * @param rootUrl root url to load from
  69407. * @param onProgress event that fires when loading progress has occured
  69408. * @param fileName Defines the name of the file to load
  69409. * @returns a promise which completes when objects have been loaded to the scene
  69410. */
  69411. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69412. /**
  69413. * Load into an asset container.
  69414. * @param scene The scene to load into
  69415. * @param data The data to import
  69416. * @param rootUrl The root url for scene and resources
  69417. * @param onProgress The callback when the load progresses
  69418. * @param fileName Defines the name of the file to load
  69419. * @returns The loaded asset container
  69420. */
  69421. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  69422. /**
  69423. * Read the OBJ file and create an Array of meshes.
  69424. * Each mesh contains all information given by the OBJ and the MTL file.
  69425. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  69426. *
  69427. * @param meshesNames
  69428. * @param scene Scene The scene where are displayed the data
  69429. * @param data String The content of the obj file
  69430. * @param rootUrl String The path to the folder
  69431. * @returns Array<AbstractMesh>
  69432. * @private
  69433. */
  69434. private _parseSolid;
  69435. }
  69436. }
  69437. declare module BABYLON {
  69438. /**
  69439. * STL file type loader.
  69440. * This is a babylon scene loader plugin.
  69441. */
  69442. export class STLFileLoader implements ISceneLoaderPlugin {
  69443. /** @hidden */
  69444. solidPattern: RegExp;
  69445. /** @hidden */
  69446. facetsPattern: RegExp;
  69447. /** @hidden */
  69448. normalPattern: RegExp;
  69449. /** @hidden */
  69450. vertexPattern: RegExp;
  69451. /**
  69452. * Defines the name of the plugin.
  69453. */
  69454. name: string;
  69455. /**
  69456. * Defines the extensions the stl loader is able to load.
  69457. * force data to come in as an ArrayBuffer
  69458. * we'll convert to string if it looks like it's an ASCII .stl
  69459. */
  69460. extensions: ISceneLoaderPluginExtensions;
  69461. /**
  69462. * Import meshes into a scene.
  69463. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  69464. * @param scene The scene to import into
  69465. * @param data The data to import
  69466. * @param rootUrl The root url for scene and resources
  69467. * @param meshes The meshes array to import into
  69468. * @param particleSystems The particle systems array to import into
  69469. * @param skeletons The skeletons array to import into
  69470. * @param onError The callback when import fails
  69471. * @returns True if successful or false otherwise
  69472. */
  69473. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  69474. /**
  69475. * Load into a scene.
  69476. * @param scene The scene to load into
  69477. * @param data The data to import
  69478. * @param rootUrl The root url for scene and resources
  69479. * @param onError The callback when import fails
  69480. * @returns true if successful or false otherwise
  69481. */
  69482. load(scene: Scene, data: any, rootUrl: string): boolean;
  69483. /**
  69484. * Load into an asset container.
  69485. * @param scene The scene to load into
  69486. * @param data The data to import
  69487. * @param rootUrl The root url for scene and resources
  69488. * @param onError The callback when import fails
  69489. * @returns The loaded asset container
  69490. */
  69491. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  69492. private _isBinary;
  69493. private _parseBinary;
  69494. private _parseASCII;
  69495. }
  69496. }
  69497. declare module BABYLON {
  69498. /**
  69499. * Class for generating OBJ data from a Babylon scene.
  69500. */
  69501. export class OBJExport {
  69502. /**
  69503. * Exports the geometry of a Mesh array in .OBJ file format (text)
  69504. * @param mesh defines the list of meshes to serialize
  69505. * @param materials defines if materials should be exported
  69506. * @param matlibname defines the name of the associated mtl file
  69507. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  69508. * @returns the OBJ content
  69509. */
  69510. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  69511. /**
  69512. * Exports the material(s) of a mesh in .MTL file format (text)
  69513. * @param mesh defines the mesh to extract the material from
  69514. * @returns the mtl content
  69515. */
  69516. static MTL(mesh: Mesh): string;
  69517. }
  69518. }
  69519. declare module BABYLON {
  69520. /** @hidden */
  69521. export var __IGLTFExporterExtension: number;
  69522. /**
  69523. * Interface for extending the exporter
  69524. * @hidden
  69525. */
  69526. export interface IGLTFExporterExtension {
  69527. /**
  69528. * The name of this extension
  69529. */
  69530. readonly name: string;
  69531. /**
  69532. * Defines whether this extension is enabled
  69533. */
  69534. enabled: boolean;
  69535. /**
  69536. * Defines whether this extension is required
  69537. */
  69538. required: boolean;
  69539. }
  69540. }
  69541. declare module BABYLON.GLTF2.Exporter {
  69542. /** @hidden */
  69543. export var __IGLTFExporterExtensionV2: number;
  69544. /**
  69545. * Interface for a glTF exporter extension
  69546. * @hidden
  69547. */
  69548. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  69549. /**
  69550. * Define this method to modify the default behavior before exporting a texture
  69551. * @param context The context when loading the asset
  69552. * @param babylonTexture The glTF texture info property
  69553. * @param mimeType The mime-type of the generated image
  69554. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  69555. */
  69556. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69557. /**
  69558. * Define this method to modify the default behavior when exporting texture info
  69559. * @param context The context when loading the asset
  69560. * @param meshPrimitive glTF mesh primitive
  69561. * @param babylonSubMesh Babylon submesh
  69562. * @param binaryWriter glTF serializer binary writer instance
  69563. * @returns nullable IMeshPrimitive promise
  69564. */
  69565. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  69566. /**
  69567. * Define this method to modify the default behavior when exporting a node
  69568. * @param context The context when exporting the node
  69569. * @param node glTF node
  69570. * @param babylonNode BabylonJS node
  69571. * @returns nullable INode promise
  69572. */
  69573. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69574. /**
  69575. * Called after the exporter state changes to EXPORTING
  69576. */
  69577. onExporting?(): void;
  69578. }
  69579. }
  69580. declare module BABYLON.GLTF2.Exporter {
  69581. /**
  69582. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  69583. * @hidden
  69584. */
  69585. export class _GLTFMaterialExporter {
  69586. /**
  69587. * Represents the dielectric specular values for R, G and B
  69588. */
  69589. private static readonly _DielectricSpecular;
  69590. /**
  69591. * Allows the maximum specular power to be defined for material calculations
  69592. */
  69593. private static readonly _MaxSpecularPower;
  69594. /**
  69595. * Mapping to store textures
  69596. */
  69597. private _textureMap;
  69598. /**
  69599. * Numeric tolerance value
  69600. */
  69601. private static readonly _Epsilon;
  69602. /**
  69603. * Reference to the glTF Exporter
  69604. */
  69605. private _exporter;
  69606. constructor(exporter: _Exporter);
  69607. /**
  69608. * Specifies if two colors are approximately equal in value
  69609. * @param color1 first color to compare to
  69610. * @param color2 second color to compare to
  69611. * @param epsilon threshold value
  69612. */
  69613. private static FuzzyEquals;
  69614. /**
  69615. * Gets the materials from a Babylon scene and converts them to glTF materials
  69616. * @param scene babylonjs scene
  69617. * @param mimeType texture mime type
  69618. * @param images array of images
  69619. * @param textures array of textures
  69620. * @param materials array of materials
  69621. * @param imageData mapping of texture names to base64 textures
  69622. * @param hasTextureCoords specifies if texture coordinates are present on the material
  69623. */
  69624. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69625. /**
  69626. * Makes a copy of the glTF material without the texture parameters
  69627. * @param originalMaterial original glTF material
  69628. * @returns glTF material without texture parameters
  69629. */
  69630. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  69631. /**
  69632. * Specifies if the material has any texture parameters present
  69633. * @param material glTF Material
  69634. * @returns boolean specifying if texture parameters are present
  69635. */
  69636. _hasTexturesPresent(material: IMaterial): boolean;
  69637. /**
  69638. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  69639. * @param babylonStandardMaterial
  69640. * @returns glTF Metallic Roughness Material representation
  69641. */
  69642. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  69643. /**
  69644. * Computes the metallic factor
  69645. * @param diffuse diffused value
  69646. * @param specular specular value
  69647. * @param oneMinusSpecularStrength one minus the specular strength
  69648. * @returns metallic value
  69649. */
  69650. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  69651. /**
  69652. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  69653. * @param glTFMaterial glTF material
  69654. * @param babylonMaterial Babylon material
  69655. */
  69656. private static _SetAlphaMode;
  69657. /**
  69658. * Converts a Babylon Standard Material to a glTF Material
  69659. * @param babylonStandardMaterial BJS Standard Material
  69660. * @param mimeType mime type to use for the textures
  69661. * @param images array of glTF image interfaces
  69662. * @param textures array of glTF texture interfaces
  69663. * @param materials array of glTF material interfaces
  69664. * @param imageData map of image file name to data
  69665. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69666. */
  69667. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69668. /**
  69669. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69670. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  69671. * @param mimeType mime type to use for the textures
  69672. * @param images array of glTF image interfaces
  69673. * @param textures array of glTF texture interfaces
  69674. * @param materials array of glTF material interfaces
  69675. * @param imageData map of image file name to data
  69676. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69677. */
  69678. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69679. /**
  69680. * Converts an image typed array buffer to a base64 image
  69681. * @param buffer typed array buffer
  69682. * @param width width of the image
  69683. * @param height height of the image
  69684. * @param mimeType mimetype of the image
  69685. * @returns base64 image string
  69686. */
  69687. private _createBase64FromCanvasAsync;
  69688. /**
  69689. * Generates a white texture based on the specified width and height
  69690. * @param width width of the texture in pixels
  69691. * @param height height of the texture in pixels
  69692. * @param scene babylonjs scene
  69693. * @returns white texture
  69694. */
  69695. private _createWhiteTexture;
  69696. /**
  69697. * 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
  69698. * @param texture1 first texture to resize
  69699. * @param texture2 second texture to resize
  69700. * @param scene babylonjs scene
  69701. * @returns resized textures or null
  69702. */
  69703. private _resizeTexturesToSameDimensions;
  69704. /**
  69705. * Converts an array of pixels to a Float32Array
  69706. * Throws an error if the pixel format is not supported
  69707. * @param pixels - array buffer containing pixel values
  69708. * @returns Float32 of pixels
  69709. */
  69710. private _convertPixelArrayToFloat32;
  69711. /**
  69712. * Convert Specular Glossiness Textures to Metallic Roughness
  69713. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  69714. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  69715. * @param diffuseTexture texture used to store diffuse information
  69716. * @param specularGlossinessTexture texture used to store specular and glossiness information
  69717. * @param factors specular glossiness material factors
  69718. * @param mimeType the mime type to use for the texture
  69719. * @returns pbr metallic roughness interface or null
  69720. */
  69721. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  69722. /**
  69723. * Converts specular glossiness material properties to metallic roughness
  69724. * @param specularGlossiness interface with specular glossiness material properties
  69725. * @returns interface with metallic roughness material properties
  69726. */
  69727. private _convertSpecularGlossinessToMetallicRoughness;
  69728. /**
  69729. * Calculates the surface reflectance, independent of lighting conditions
  69730. * @param color Color source to calculate brightness from
  69731. * @returns number representing the perceived brightness, or zero if color is undefined
  69732. */
  69733. private _getPerceivedBrightness;
  69734. /**
  69735. * Returns the maximum color component value
  69736. * @param color
  69737. * @returns maximum color component value, or zero if color is null or undefined
  69738. */
  69739. private _getMaxComponent;
  69740. /**
  69741. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  69742. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69743. * @param mimeType mime type to use for the textures
  69744. * @param images array of glTF image interfaces
  69745. * @param textures array of glTF texture interfaces
  69746. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  69747. * @param imageData map of image file name to data
  69748. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69749. * @returns glTF PBR Metallic Roughness factors
  69750. */
  69751. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  69752. private _getGLTFTextureSampler;
  69753. private _getGLTFTextureWrapMode;
  69754. private _getGLTFTextureWrapModesSampler;
  69755. /**
  69756. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  69757. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69758. * @param mimeType mime type to use for the textures
  69759. * @param images array of glTF image interfaces
  69760. * @param textures array of glTF texture interfaces
  69761. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  69762. * @param imageData map of image file name to data
  69763. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69764. * @returns glTF PBR Metallic Roughness factors
  69765. */
  69766. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  69767. /**
  69768. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69769. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69770. * @param mimeType mime type to use for the textures
  69771. * @param images array of glTF image interfaces
  69772. * @param textures array of glTF texture interfaces
  69773. * @param materials array of glTF material interfaces
  69774. * @param imageData map of image file name to data
  69775. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69776. */
  69777. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69778. private setMetallicRoughnessPbrMaterial;
  69779. private getPixelsFromTexture;
  69780. /**
  69781. * Extracts a texture from a Babylon texture into file data and glTF data
  69782. * @param babylonTexture Babylon texture to extract
  69783. * @param mimeType Mime Type of the babylonTexture
  69784. * @return glTF texture info, or null if the texture format is not supported
  69785. */
  69786. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  69787. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  69788. /**
  69789. * Builds a texture from base64 string
  69790. * @param base64Texture base64 texture string
  69791. * @param baseTextureName Name to use for the texture
  69792. * @param mimeType image mime type for the texture
  69793. * @param images array of images
  69794. * @param textures array of textures
  69795. * @param imageData map of image data
  69796. * @returns glTF texture info, or null if the texture format is not supported
  69797. */
  69798. private _getTextureInfoFromBase64;
  69799. }
  69800. }
  69801. declare module BABYLON {
  69802. /**
  69803. * Class for holding and downloading glTF file data
  69804. */
  69805. export class GLTFData {
  69806. /**
  69807. * Object which contains the file name as the key and its data as the value
  69808. */
  69809. glTFFiles: {
  69810. [fileName: string]: string | Blob;
  69811. };
  69812. /**
  69813. * Initializes the glTF file object
  69814. */
  69815. constructor();
  69816. /**
  69817. * Downloads the glTF data as files based on their names and data
  69818. */
  69819. downloadFiles(): void;
  69820. }
  69821. }
  69822. declare module BABYLON {
  69823. /**
  69824. * Holds a collection of exporter options and parameters
  69825. */
  69826. export interface IExportOptions {
  69827. /**
  69828. * Function which indicates whether a babylon node should be exported or not
  69829. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  69830. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  69831. */
  69832. shouldExportNode?(node: Node): boolean;
  69833. /**
  69834. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  69835. * @param metadata source metadata to read from
  69836. * @returns the data to store to glTF node extras
  69837. */
  69838. metadataSelector?(metadata: any): any;
  69839. /**
  69840. * The sample rate to bake animation curves
  69841. */
  69842. animationSampleRate?: number;
  69843. /**
  69844. * Begin serialization without waiting for the scene to be ready
  69845. */
  69846. exportWithoutWaitingForScene?: boolean;
  69847. }
  69848. /**
  69849. * Class for generating glTF data from a Babylon scene.
  69850. */
  69851. export class GLTF2Export {
  69852. /**
  69853. * Exports the geometry of the scene to .gltf file format asynchronously
  69854. * @param scene Babylon scene with scene hierarchy information
  69855. * @param filePrefix File prefix to use when generating the glTF file
  69856. * @param options Exporter options
  69857. * @returns Returns an object with a .gltf file and associates texture names
  69858. * as keys and their data and paths as values
  69859. */
  69860. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69861. private static _PreExportAsync;
  69862. private static _PostExportAsync;
  69863. /**
  69864. * Exports the geometry of the scene to .glb file format asychronously
  69865. * @param scene Babylon scene with scene hierarchy information
  69866. * @param filePrefix File prefix to use when generating glb file
  69867. * @param options Exporter options
  69868. * @returns Returns an object with a .glb filename as key and data as value
  69869. */
  69870. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69871. }
  69872. }
  69873. declare module BABYLON.GLTF2.Exporter {
  69874. /**
  69875. * @hidden
  69876. */
  69877. export class _GLTFUtilities {
  69878. /**
  69879. * Creates a buffer view based on the supplied arguments
  69880. * @param bufferIndex index value of the specified buffer
  69881. * @param byteOffset byte offset value
  69882. * @param byteLength byte length of the bufferView
  69883. * @param byteStride byte distance between conequential elements
  69884. * @param name name of the buffer view
  69885. * @returns bufferView for glTF
  69886. */
  69887. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  69888. /**
  69889. * Creates an accessor based on the supplied arguments
  69890. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  69891. * @param name The name of the accessor
  69892. * @param type The type of the accessor
  69893. * @param componentType The datatype of components in the attribute
  69894. * @param count The number of attributes referenced by this accessor
  69895. * @param byteOffset The offset relative to the start of the bufferView in bytes
  69896. * @param min Minimum value of each component in this attribute
  69897. * @param max Maximum value of each component in this attribute
  69898. * @returns accessor for glTF
  69899. */
  69900. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  69901. /**
  69902. * Calculates the minimum and maximum values of an array of position floats
  69903. * @param positions Positions array of a mesh
  69904. * @param vertexStart Starting vertex offset to calculate min and max values
  69905. * @param vertexCount Number of vertices to check for min and max values
  69906. * @returns min number array and max number array
  69907. */
  69908. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  69909. min: number[];
  69910. max: number[];
  69911. };
  69912. /**
  69913. * Converts a new right-handed Vector3
  69914. * @param vector vector3 array
  69915. * @returns right-handed Vector3
  69916. */
  69917. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  69918. /**
  69919. * Converts a Vector3 to right-handed
  69920. * @param vector Vector3 to convert to right-handed
  69921. */
  69922. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  69923. /**
  69924. * Converts a three element number array to right-handed
  69925. * @param vector number array to convert to right-handed
  69926. */
  69927. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  69928. /**
  69929. * Converts a new right-handed Vector3
  69930. * @param vector vector3 array
  69931. * @returns right-handed Vector3
  69932. */
  69933. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  69934. /**
  69935. * Converts a Vector3 to right-handed
  69936. * @param vector Vector3 to convert to right-handed
  69937. */
  69938. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  69939. /**
  69940. * Converts a three element number array to right-handed
  69941. * @param vector number array to convert to right-handed
  69942. */
  69943. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  69944. /**
  69945. * Converts a Vector4 to right-handed
  69946. * @param vector Vector4 to convert to right-handed
  69947. */
  69948. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  69949. /**
  69950. * Converts a Vector4 to right-handed
  69951. * @param vector Vector4 to convert to right-handed
  69952. */
  69953. static _GetRightHandedArray4FromRef(vector: number[]): void;
  69954. /**
  69955. * Converts a Quaternion to right-handed
  69956. * @param quaternion Source quaternion to convert to right-handed
  69957. */
  69958. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  69959. /**
  69960. * Converts a Quaternion to right-handed
  69961. * @param quaternion Source quaternion to convert to right-handed
  69962. */
  69963. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  69964. static _NormalizeTangentFromRef(tangent: Vector4): void;
  69965. }
  69966. }
  69967. declare module BABYLON.GLTF2.Exporter {
  69968. /**
  69969. * Converts Babylon Scene into glTF 2.0.
  69970. * @hidden
  69971. */
  69972. export class _Exporter {
  69973. /**
  69974. * Stores the glTF to export
  69975. */
  69976. _glTF: IGLTF;
  69977. /**
  69978. * Stores all generated buffer views, which represents views into the main glTF buffer data
  69979. */
  69980. _bufferViews: IBufferView[];
  69981. /**
  69982. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  69983. */
  69984. _accessors: IAccessor[];
  69985. /**
  69986. * Stores all the generated nodes, which contains transform and/or mesh information per node
  69987. */
  69988. private _nodes;
  69989. /**
  69990. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  69991. */
  69992. private _scenes;
  69993. /**
  69994. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  69995. */
  69996. private _meshes;
  69997. /**
  69998. * Stores all the generated material information, which represents the appearance of each primitive
  69999. */
  70000. _materials: IMaterial[];
  70001. _materialMap: {
  70002. [materialID: number]: number;
  70003. };
  70004. /**
  70005. * Stores all the generated texture information, which is referenced by glTF materials
  70006. */
  70007. _textures: ITexture[];
  70008. /**
  70009. * Stores all the generated image information, which is referenced by glTF textures
  70010. */
  70011. _images: IImage[];
  70012. /**
  70013. * Stores all the texture samplers
  70014. */
  70015. _samplers: ISampler[];
  70016. /**
  70017. * Stores all the generated animation samplers, which is referenced by glTF animations
  70018. */
  70019. /**
  70020. * Stores the animations for glTF models
  70021. */
  70022. private _animations;
  70023. /**
  70024. * Stores the total amount of bytes stored in the glTF buffer
  70025. */
  70026. private _totalByteLength;
  70027. /**
  70028. * Stores a reference to the Babylon scene containing the source geometry and material information
  70029. */
  70030. _babylonScene: Scene;
  70031. /**
  70032. * Stores a map of the image data, where the key is the file name and the value
  70033. * is the image data
  70034. */
  70035. _imageData: {
  70036. [fileName: string]: {
  70037. data: Uint8Array;
  70038. mimeType: ImageMimeType;
  70039. };
  70040. };
  70041. /**
  70042. * Stores a map of the unique id of a node to its index in the node array
  70043. */
  70044. private _nodeMap;
  70045. /**
  70046. * Specifies if the Babylon scene should be converted to right-handed on export
  70047. */
  70048. _convertToRightHandedSystem: boolean;
  70049. /**
  70050. * Baked animation sample rate
  70051. */
  70052. private _animationSampleRate;
  70053. private _options;
  70054. private _localEngine;
  70055. _glTFMaterialExporter: _GLTFMaterialExporter;
  70056. private _extensions;
  70057. private static _ExtensionNames;
  70058. private static _ExtensionFactories;
  70059. private _applyExtensions;
  70060. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  70061. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  70062. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70063. private _forEachExtensions;
  70064. private _extensionsOnExporting;
  70065. /**
  70066. * Load glTF serializer extensions
  70067. */
  70068. private _loadExtensions;
  70069. /**
  70070. * Creates a glTF Exporter instance, which can accept optional exporter options
  70071. * @param babylonScene Babylon scene object
  70072. * @param options Options to modify the behavior of the exporter
  70073. */
  70074. constructor(babylonScene: Scene, options?: IExportOptions);
  70075. /**
  70076. * Registers a glTF exporter extension
  70077. * @param name Name of the extension to export
  70078. * @param factory The factory function that creates the exporter extension
  70079. */
  70080. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  70081. /**
  70082. * Un-registers an exporter extension
  70083. * @param name The name fo the exporter extension
  70084. * @returns A boolean indicating whether the extension has been un-registered
  70085. */
  70086. static UnregisterExtension(name: string): boolean;
  70087. /**
  70088. * Lazy load a local engine with premultiplied alpha set to false
  70089. */
  70090. _getLocalEngine(): Engine;
  70091. private reorderIndicesBasedOnPrimitiveMode;
  70092. /**
  70093. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  70094. * clock-wise during export to glTF
  70095. * @param submesh BabylonJS submesh
  70096. * @param primitiveMode Primitive mode of the mesh
  70097. * @param sideOrientation the winding order of the submesh
  70098. * @param vertexBufferKind The type of vertex attribute
  70099. * @param meshAttributeArray The vertex attribute data
  70100. * @param byteOffset The offset to the binary data
  70101. * @param binaryWriter The binary data for the glTF file
  70102. */
  70103. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  70104. /**
  70105. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  70106. * clock-wise during export to glTF
  70107. * @param submesh BabylonJS submesh
  70108. * @param primitiveMode Primitive mode of the mesh
  70109. * @param sideOrientation the winding order of the submesh
  70110. * @param vertexBufferKind The type of vertex attribute
  70111. * @param meshAttributeArray The vertex attribute data
  70112. * @param byteOffset The offset to the binary data
  70113. * @param binaryWriter The binary data for the glTF file
  70114. */
  70115. private reorderTriangleFillMode;
  70116. /**
  70117. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  70118. * clock-wise during export to glTF
  70119. * @param submesh BabylonJS submesh
  70120. * @param primitiveMode Primitive mode of the mesh
  70121. * @param sideOrientation the winding order of the submesh
  70122. * @param vertexBufferKind The type of vertex attribute
  70123. * @param meshAttributeArray The vertex attribute data
  70124. * @param byteOffset The offset to the binary data
  70125. * @param binaryWriter The binary data for the glTF file
  70126. */
  70127. private reorderTriangleStripDrawMode;
  70128. /**
  70129. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  70130. * clock-wise during export to glTF
  70131. * @param submesh BabylonJS submesh
  70132. * @param primitiveMode Primitive mode of the mesh
  70133. * @param sideOrientation the winding order of the submesh
  70134. * @param vertexBufferKind The type of vertex attribute
  70135. * @param meshAttributeArray The vertex attribute data
  70136. * @param byteOffset The offset to the binary data
  70137. * @param binaryWriter The binary data for the glTF file
  70138. */
  70139. private reorderTriangleFanMode;
  70140. /**
  70141. * Writes the vertex attribute data to binary
  70142. * @param vertices The vertices to write to the binary writer
  70143. * @param byteOffset The offset into the binary writer to overwrite binary data
  70144. * @param vertexAttributeKind The vertex attribute type
  70145. * @param meshAttributeArray The vertex attribute data
  70146. * @param binaryWriter The writer containing the binary data
  70147. */
  70148. private writeVertexAttributeData;
  70149. /**
  70150. * Writes mesh attribute data to a data buffer
  70151. * Returns the bytelength of the data
  70152. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  70153. * @param meshAttributeArray Array containing the attribute data
  70154. * @param binaryWriter The buffer to write the binary data to
  70155. * @param indices Used to specify the order of the vertex data
  70156. */
  70157. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  70158. /**
  70159. * Generates glTF json data
  70160. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  70161. * @param glTFPrefix Text to use when prefixing a glTF file
  70162. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  70163. * @returns json data as string
  70164. */
  70165. private generateJSON;
  70166. /**
  70167. * Generates data for .gltf and .bin files based on the glTF prefix string
  70168. * @param glTFPrefix Text to use when prefixing a glTF file
  70169. * @returns GLTFData with glTF file data
  70170. */
  70171. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  70172. /**
  70173. * Creates a binary buffer for glTF
  70174. * @returns array buffer for binary data
  70175. */
  70176. private _generateBinaryAsync;
  70177. /**
  70178. * Pads the number to a multiple of 4
  70179. * @param num number to pad
  70180. * @returns padded number
  70181. */
  70182. private _getPadding;
  70183. /**
  70184. * Generates a glb file from the json and binary data
  70185. * Returns an object with the glb file name as the key and data as the value
  70186. * @param glTFPrefix
  70187. * @returns object with glb filename as key and data as value
  70188. */
  70189. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  70190. /**
  70191. * Sets the TRS for each node
  70192. * @param node glTF Node for storing the transformation data
  70193. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  70194. */
  70195. private setNodeTransformation;
  70196. private getVertexBufferFromMesh;
  70197. /**
  70198. * Creates a bufferview based on the vertices type for the Babylon mesh
  70199. * @param kind Indicates the type of vertices data
  70200. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  70201. * @param binaryWriter The buffer to write the bufferview data to
  70202. */
  70203. private createBufferViewKind;
  70204. /**
  70205. * The primitive mode of the Babylon mesh
  70206. * @param babylonMesh The BabylonJS mesh
  70207. */
  70208. private getMeshPrimitiveMode;
  70209. /**
  70210. * Sets the primitive mode of the glTF mesh primitive
  70211. * @param meshPrimitive glTF mesh primitive
  70212. * @param primitiveMode The primitive mode
  70213. */
  70214. private setPrimitiveMode;
  70215. /**
  70216. * Sets the vertex attribute accessor based of the glTF mesh primitive
  70217. * @param meshPrimitive glTF mesh primitive
  70218. * @param attributeKind vertex attribute
  70219. * @returns boolean specifying if uv coordinates are present
  70220. */
  70221. private setAttributeKind;
  70222. /**
  70223. * Sets data for the primitive attributes of each submesh
  70224. * @param mesh glTF Mesh object to store the primitive attribute information
  70225. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  70226. * @param binaryWriter Buffer to write the attribute data to
  70227. */
  70228. private setPrimitiveAttributesAsync;
  70229. /**
  70230. * Creates a glTF scene based on the array of meshes
  70231. * Returns the the total byte offset
  70232. * @param babylonScene Babylon scene to get the mesh data from
  70233. * @param binaryWriter Buffer to write binary data to
  70234. */
  70235. private createSceneAsync;
  70236. /**
  70237. * Creates a mapping of Node unique id to node index and handles animations
  70238. * @param babylonScene Babylon Scene
  70239. * @param nodes Babylon transform nodes
  70240. * @param binaryWriter Buffer to write binary data to
  70241. * @returns Node mapping of unique id to index
  70242. */
  70243. private createNodeMapAndAnimationsAsync;
  70244. /**
  70245. * Creates a glTF node from a Babylon mesh
  70246. * @param babylonMesh Source Babylon mesh
  70247. * @param binaryWriter Buffer for storing geometry data
  70248. * @returns glTF node
  70249. */
  70250. private createNodeAsync;
  70251. }
  70252. /**
  70253. * @hidden
  70254. *
  70255. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  70256. */
  70257. export class _BinaryWriter {
  70258. /**
  70259. * Array buffer which stores all binary data
  70260. */
  70261. private _arrayBuffer;
  70262. /**
  70263. * View of the array buffer
  70264. */
  70265. private _dataView;
  70266. /**
  70267. * byte offset of data in array buffer
  70268. */
  70269. private _byteOffset;
  70270. /**
  70271. * Initialize binary writer with an initial byte length
  70272. * @param byteLength Initial byte length of the array buffer
  70273. */
  70274. constructor(byteLength: number);
  70275. /**
  70276. * Resize the array buffer to the specified byte length
  70277. * @param byteLength
  70278. */
  70279. private resizeBuffer;
  70280. /**
  70281. * Get an array buffer with the length of the byte offset
  70282. * @returns ArrayBuffer resized to the byte offset
  70283. */
  70284. getArrayBuffer(): ArrayBuffer;
  70285. /**
  70286. * Get the byte offset of the array buffer
  70287. * @returns byte offset
  70288. */
  70289. getByteOffset(): number;
  70290. /**
  70291. * Stores an UInt8 in the array buffer
  70292. * @param entry
  70293. * @param byteOffset If defined, specifies where to set the value as an offset.
  70294. */
  70295. setUInt8(entry: number, byteOffset?: number): void;
  70296. /**
  70297. * Gets an UInt32 in the array buffer
  70298. * @param entry
  70299. * @param byteOffset If defined, specifies where to set the value as an offset.
  70300. */
  70301. getUInt32(byteOffset: number): number;
  70302. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  70303. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  70304. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  70305. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  70306. /**
  70307. * Stores a Float32 in the array buffer
  70308. * @param entry
  70309. */
  70310. setFloat32(entry: number, byteOffset?: number): void;
  70311. /**
  70312. * Stores an UInt32 in the array buffer
  70313. * @param entry
  70314. * @param byteOffset If defined, specifies where to set the value as an offset.
  70315. */
  70316. setUInt32(entry: number, byteOffset?: number): void;
  70317. }
  70318. }
  70319. declare module BABYLON.GLTF2.Exporter {
  70320. /**
  70321. * @hidden
  70322. * Interface to store animation data.
  70323. */
  70324. export interface _IAnimationData {
  70325. /**
  70326. * Keyframe data.
  70327. */
  70328. inputs: number[];
  70329. /**
  70330. * Value data.
  70331. */
  70332. outputs: number[][];
  70333. /**
  70334. * Animation interpolation data.
  70335. */
  70336. samplerInterpolation: AnimationSamplerInterpolation;
  70337. /**
  70338. * Minimum keyframe value.
  70339. */
  70340. inputsMin: number;
  70341. /**
  70342. * Maximum keyframe value.
  70343. */
  70344. inputsMax: number;
  70345. }
  70346. /**
  70347. * @hidden
  70348. */
  70349. export interface _IAnimationInfo {
  70350. /**
  70351. * The target channel for the animation
  70352. */
  70353. animationChannelTargetPath: AnimationChannelTargetPath;
  70354. /**
  70355. * The glTF accessor type for the data.
  70356. */
  70357. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  70358. /**
  70359. * Specifies if quaternions should be used.
  70360. */
  70361. useQuaternion: boolean;
  70362. }
  70363. /**
  70364. * @hidden
  70365. * Utility class for generating glTF animation data from BabylonJS.
  70366. */
  70367. export class _GLTFAnimation {
  70368. /**
  70369. * @ignore
  70370. *
  70371. * Creates glTF channel animation from BabylonJS animation.
  70372. * @param babylonTransformNode - BabylonJS mesh.
  70373. * @param animation - animation.
  70374. * @param animationChannelTargetPath - The target animation channel.
  70375. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  70376. * @param useQuaternion - Specifies if quaternions are used.
  70377. * @returns nullable IAnimationData
  70378. */
  70379. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  70380. private static _DeduceAnimationInfo;
  70381. /**
  70382. * @ignore
  70383. * Create node animations from the transform node animations
  70384. * @param babylonNode
  70385. * @param runtimeGLTFAnimation
  70386. * @param idleGLTFAnimations
  70387. * @param nodeMap
  70388. * @param nodes
  70389. * @param binaryWriter
  70390. * @param bufferViews
  70391. * @param accessors
  70392. * @param convertToRightHandedSystem
  70393. */
  70394. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  70395. [key: number]: number;
  70396. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70397. /**
  70398. * @ignore
  70399. * Create node animations from the animation groups
  70400. * @param babylonScene
  70401. * @param glTFAnimations
  70402. * @param nodeMap
  70403. * @param nodes
  70404. * @param binaryWriter
  70405. * @param bufferViews
  70406. * @param accessors
  70407. * @param convertToRightHandedSystem
  70408. */
  70409. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  70410. [key: number]: number;
  70411. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70412. private static AddAnimation;
  70413. /**
  70414. * Create a baked animation
  70415. * @param babylonTransformNode BabylonJS mesh
  70416. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  70417. * @param animationChannelTargetPath animation target channel
  70418. * @param minFrame minimum animation frame
  70419. * @param maxFrame maximum animation frame
  70420. * @param fps frames per second of the animation
  70421. * @param inputs input key frames of the animation
  70422. * @param outputs output key frame data of the animation
  70423. * @param convertToRightHandedSystem converts the values to right-handed
  70424. * @param useQuaternion specifies if quaternions should be used
  70425. */
  70426. private static _CreateBakedAnimation;
  70427. private static _ConvertFactorToVector3OrQuaternion;
  70428. private static _SetInterpolatedValue;
  70429. /**
  70430. * Creates linear animation from the animation key frames
  70431. * @param babylonTransformNode BabylonJS mesh
  70432. * @param animation BabylonJS animation
  70433. * @param animationChannelTargetPath The target animation channel
  70434. * @param frameDelta The difference between the last and first frame of the animation
  70435. * @param inputs Array to store the key frame times
  70436. * @param outputs Array to store the key frame data
  70437. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70438. * @param useQuaternion Specifies if quaternions are used in the animation
  70439. */
  70440. private static _CreateLinearOrStepAnimation;
  70441. /**
  70442. * Creates cubic spline animation from the animation key frames
  70443. * @param babylonTransformNode BabylonJS mesh
  70444. * @param animation BabylonJS animation
  70445. * @param animationChannelTargetPath The target animation channel
  70446. * @param frameDelta The difference between the last and first frame of the animation
  70447. * @param inputs Array to store the key frame times
  70448. * @param outputs Array to store the key frame data
  70449. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70450. * @param useQuaternion Specifies if quaternions are used in the animation
  70451. */
  70452. private static _CreateCubicSplineAnimation;
  70453. private static _GetBasePositionRotationOrScale;
  70454. /**
  70455. * Adds a key frame value
  70456. * @param keyFrame
  70457. * @param animation
  70458. * @param outputs
  70459. * @param animationChannelTargetPath
  70460. * @param basePositionRotationOrScale
  70461. * @param convertToRightHandedSystem
  70462. * @param useQuaternion
  70463. */
  70464. private static _AddKeyframeValue;
  70465. /**
  70466. * Determine the interpolation based on the key frames
  70467. * @param keyFrames
  70468. * @param animationChannelTargetPath
  70469. * @param useQuaternion
  70470. */
  70471. private static _DeduceInterpolation;
  70472. /**
  70473. * Adds an input tangent or output tangent to the output data
  70474. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  70475. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  70476. * @param outputs The animation data by keyframe
  70477. * @param animationChannelTargetPath The target animation channel
  70478. * @param interpolation The interpolation type
  70479. * @param keyFrame The key frame with the animation data
  70480. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  70481. * @param useQuaternion Specifies if quaternions are used
  70482. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  70483. */
  70484. private static AddSplineTangent;
  70485. /**
  70486. * Get the minimum and maximum key frames' frame values
  70487. * @param keyFrames animation key frames
  70488. * @returns the minimum and maximum key frame value
  70489. */
  70490. private static calculateMinMaxKeyFrames;
  70491. }
  70492. }
  70493. declare module BABYLON.GLTF2.Exporter {
  70494. /** @hidden */
  70495. export var textureTransformPixelShader: {
  70496. name: string;
  70497. shader: string;
  70498. };
  70499. }
  70500. declare module BABYLON.GLTF2.Exporter.Extensions {
  70501. /**
  70502. * @hidden
  70503. */
  70504. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  70505. /** Name of this extension */
  70506. readonly name: string;
  70507. /** Defines whether this extension is enabled */
  70508. enabled: boolean;
  70509. /** Defines whether this extension is required */
  70510. required: boolean;
  70511. /** Reference to the glTF exporter */
  70512. private _exporter;
  70513. constructor(exporter: _Exporter);
  70514. dispose(): void;
  70515. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70516. /**
  70517. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  70518. * @param babylonTexture
  70519. * @param offset
  70520. * @param rotation
  70521. * @param scale
  70522. * @param scene
  70523. */
  70524. private _textureTransformTextureAsync;
  70525. }
  70526. }
  70527. declare module BABYLON.GLTF2.Exporter.Extensions {
  70528. /**
  70529. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  70530. */
  70531. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  70532. /** The name of this extension. */
  70533. readonly name: string;
  70534. /** Defines whether this extension is enabled. */
  70535. enabled: boolean;
  70536. /** Defines whether this extension is required */
  70537. required: boolean;
  70538. /** Reference to the glTF exporter */
  70539. private _exporter;
  70540. private _lights;
  70541. /** @hidden */
  70542. constructor(exporter: _Exporter);
  70543. /** @hidden */
  70544. dispose(): void;
  70545. /** @hidden */
  70546. onExporting(): void;
  70547. /**
  70548. * Define this method to modify the default behavior when exporting a node
  70549. * @param context The context when exporting the node
  70550. * @param node glTF node
  70551. * @param babylonNode BabylonJS node
  70552. * @returns nullable INode promise
  70553. */
  70554. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70555. }
  70556. }
  70557. declare module BABYLON {
  70558. /**
  70559. * Class for generating STL data from a Babylon scene.
  70560. */
  70561. export class STLExport {
  70562. /**
  70563. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  70564. * @param meshes list defines the mesh to serialize
  70565. * @param download triggers the automatic download of the file.
  70566. * @param fileName changes the downloads fileName.
  70567. * @param binary changes the STL to a binary type.
  70568. * @param isLittleEndian toggle for binary type exporter.
  70569. * @returns the STL as UTF8 string
  70570. */
  70571. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  70572. }
  70573. }
  70574. declare module "babylonjs-gltf2interface" {
  70575. export = BABYLON.GLTF2;
  70576. }
  70577. /**
  70578. * Module for glTF 2.0 Interface
  70579. */
  70580. declare module BABYLON.GLTF2 {
  70581. /**
  70582. * The datatype of the components in the attribute
  70583. */
  70584. const enum AccessorComponentType {
  70585. /**
  70586. * Byte
  70587. */
  70588. BYTE = 5120,
  70589. /**
  70590. * Unsigned Byte
  70591. */
  70592. UNSIGNED_BYTE = 5121,
  70593. /**
  70594. * Short
  70595. */
  70596. SHORT = 5122,
  70597. /**
  70598. * Unsigned Short
  70599. */
  70600. UNSIGNED_SHORT = 5123,
  70601. /**
  70602. * Unsigned Int
  70603. */
  70604. UNSIGNED_INT = 5125,
  70605. /**
  70606. * Float
  70607. */
  70608. FLOAT = 5126,
  70609. }
  70610. /**
  70611. * Specifies if the attirbute is a scalar, vector, or matrix
  70612. */
  70613. const enum AccessorType {
  70614. /**
  70615. * Scalar
  70616. */
  70617. SCALAR = "SCALAR",
  70618. /**
  70619. * Vector2
  70620. */
  70621. VEC2 = "VEC2",
  70622. /**
  70623. * Vector3
  70624. */
  70625. VEC3 = "VEC3",
  70626. /**
  70627. * Vector4
  70628. */
  70629. VEC4 = "VEC4",
  70630. /**
  70631. * Matrix2x2
  70632. */
  70633. MAT2 = "MAT2",
  70634. /**
  70635. * Matrix3x3
  70636. */
  70637. MAT3 = "MAT3",
  70638. /**
  70639. * Matrix4x4
  70640. */
  70641. MAT4 = "MAT4",
  70642. }
  70643. /**
  70644. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70645. */
  70646. const enum AnimationChannelTargetPath {
  70647. /**
  70648. * Translation
  70649. */
  70650. TRANSLATION = "translation",
  70651. /**
  70652. * Rotation
  70653. */
  70654. ROTATION = "rotation",
  70655. /**
  70656. * Scale
  70657. */
  70658. SCALE = "scale",
  70659. /**
  70660. * Weights
  70661. */
  70662. WEIGHTS = "weights",
  70663. }
  70664. /**
  70665. * Interpolation algorithm
  70666. */
  70667. const enum AnimationSamplerInterpolation {
  70668. /**
  70669. * The animated values are linearly interpolated between keyframes
  70670. */
  70671. LINEAR = "LINEAR",
  70672. /**
  70673. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  70674. */
  70675. STEP = "STEP",
  70676. /**
  70677. * The animation's interpolation is computed using a cubic spline with specified tangents
  70678. */
  70679. CUBICSPLINE = "CUBICSPLINE",
  70680. }
  70681. /**
  70682. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70683. */
  70684. const enum CameraType {
  70685. /**
  70686. * A perspective camera containing properties to create a perspective projection matrix
  70687. */
  70688. PERSPECTIVE = "perspective",
  70689. /**
  70690. * An orthographic camera containing properties to create an orthographic projection matrix
  70691. */
  70692. ORTHOGRAPHIC = "orthographic",
  70693. }
  70694. /**
  70695. * The mime-type of the image
  70696. */
  70697. const enum ImageMimeType {
  70698. /**
  70699. * JPEG Mime-type
  70700. */
  70701. JPEG = "image/jpeg",
  70702. /**
  70703. * PNG Mime-type
  70704. */
  70705. PNG = "image/png",
  70706. }
  70707. /**
  70708. * The alpha rendering mode of the material
  70709. */
  70710. const enum MaterialAlphaMode {
  70711. /**
  70712. * The alpha value is ignored and the rendered output is fully opaque
  70713. */
  70714. OPAQUE = "OPAQUE",
  70715. /**
  70716. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  70717. */
  70718. MASK = "MASK",
  70719. /**
  70720. * 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)
  70721. */
  70722. BLEND = "BLEND",
  70723. }
  70724. /**
  70725. * The type of the primitives to render
  70726. */
  70727. const enum MeshPrimitiveMode {
  70728. /**
  70729. * Points
  70730. */
  70731. POINTS = 0,
  70732. /**
  70733. * Lines
  70734. */
  70735. LINES = 1,
  70736. /**
  70737. * Line Loop
  70738. */
  70739. LINE_LOOP = 2,
  70740. /**
  70741. * Line Strip
  70742. */
  70743. LINE_STRIP = 3,
  70744. /**
  70745. * Triangles
  70746. */
  70747. TRIANGLES = 4,
  70748. /**
  70749. * Triangle Strip
  70750. */
  70751. TRIANGLE_STRIP = 5,
  70752. /**
  70753. * Triangle Fan
  70754. */
  70755. TRIANGLE_FAN = 6,
  70756. }
  70757. /**
  70758. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70759. */
  70760. const enum TextureMagFilter {
  70761. /**
  70762. * Nearest
  70763. */
  70764. NEAREST = 9728,
  70765. /**
  70766. * Linear
  70767. */
  70768. LINEAR = 9729,
  70769. }
  70770. /**
  70771. * Minification filter. All valid values correspond to WebGL enums
  70772. */
  70773. const enum TextureMinFilter {
  70774. /**
  70775. * Nearest
  70776. */
  70777. NEAREST = 9728,
  70778. /**
  70779. * Linear
  70780. */
  70781. LINEAR = 9729,
  70782. /**
  70783. * Nearest Mip-Map Nearest
  70784. */
  70785. NEAREST_MIPMAP_NEAREST = 9984,
  70786. /**
  70787. * Linear Mipmap Nearest
  70788. */
  70789. LINEAR_MIPMAP_NEAREST = 9985,
  70790. /**
  70791. * Nearest Mipmap Linear
  70792. */
  70793. NEAREST_MIPMAP_LINEAR = 9986,
  70794. /**
  70795. * Linear Mipmap Linear
  70796. */
  70797. LINEAR_MIPMAP_LINEAR = 9987,
  70798. }
  70799. /**
  70800. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70801. */
  70802. const enum TextureWrapMode {
  70803. /**
  70804. * Clamp to Edge
  70805. */
  70806. CLAMP_TO_EDGE = 33071,
  70807. /**
  70808. * Mirrored Repeat
  70809. */
  70810. MIRRORED_REPEAT = 33648,
  70811. /**
  70812. * Repeat
  70813. */
  70814. REPEAT = 10497,
  70815. }
  70816. /**
  70817. * glTF Property
  70818. */
  70819. interface IProperty {
  70820. /**
  70821. * Dictionary object with extension-specific objects
  70822. */
  70823. extensions?: {
  70824. [key: string]: any;
  70825. };
  70826. /**
  70827. * Application-Specific data
  70828. */
  70829. extras?: any;
  70830. }
  70831. /**
  70832. * glTF Child of Root Property
  70833. */
  70834. interface IChildRootProperty extends IProperty {
  70835. /**
  70836. * The user-defined name of this object
  70837. */
  70838. name?: string;
  70839. }
  70840. /**
  70841. * Indices of those attributes that deviate from their initialization value
  70842. */
  70843. interface IAccessorSparseIndices extends IProperty {
  70844. /**
  70845. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70846. */
  70847. bufferView: number;
  70848. /**
  70849. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70850. */
  70851. byteOffset?: number;
  70852. /**
  70853. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  70854. */
  70855. componentType: AccessorComponentType;
  70856. }
  70857. /**
  70858. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  70859. */
  70860. interface IAccessorSparseValues extends IProperty {
  70861. /**
  70862. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70863. */
  70864. bufferView: number;
  70865. /**
  70866. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70867. */
  70868. byteOffset?: number;
  70869. }
  70870. /**
  70871. * Sparse storage of attributes that deviate from their initialization value
  70872. */
  70873. interface IAccessorSparse extends IProperty {
  70874. /**
  70875. * The number of attributes encoded in this sparse accessor
  70876. */
  70877. count: number;
  70878. /**
  70879. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  70880. */
  70881. indices: IAccessorSparseIndices;
  70882. /**
  70883. * 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
  70884. */
  70885. values: IAccessorSparseValues;
  70886. }
  70887. /**
  70888. * 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
  70889. */
  70890. interface IAccessor extends IChildRootProperty {
  70891. /**
  70892. * The index of the bufferview
  70893. */
  70894. bufferView?: number;
  70895. /**
  70896. * The offset relative to the start of the bufferView in bytes
  70897. */
  70898. byteOffset?: number;
  70899. /**
  70900. * The datatype of components in the attribute
  70901. */
  70902. componentType: AccessorComponentType;
  70903. /**
  70904. * Specifies whether integer data values should be normalized
  70905. */
  70906. normalized?: boolean;
  70907. /**
  70908. * The number of attributes referenced by this accessor
  70909. */
  70910. count: number;
  70911. /**
  70912. * Specifies if the attribute is a scalar, vector, or matrix
  70913. */
  70914. type: AccessorType;
  70915. /**
  70916. * Maximum value of each component in this attribute
  70917. */
  70918. max?: number[];
  70919. /**
  70920. * Minimum value of each component in this attribute
  70921. */
  70922. min?: number[];
  70923. /**
  70924. * Sparse storage of attributes that deviate from their initialization value
  70925. */
  70926. sparse?: IAccessorSparse;
  70927. }
  70928. /**
  70929. * Targets an animation's sampler at a node's property
  70930. */
  70931. interface IAnimationChannel extends IProperty {
  70932. /**
  70933. * The index of a sampler in this animation used to compute the value for the target
  70934. */
  70935. sampler: number;
  70936. /**
  70937. * The index of the node and TRS property to target
  70938. */
  70939. target: IAnimationChannelTarget;
  70940. }
  70941. /**
  70942. * The index of the node and TRS property that an animation channel targets
  70943. */
  70944. interface IAnimationChannelTarget extends IProperty {
  70945. /**
  70946. * The index of the node to target
  70947. */
  70948. node: number;
  70949. /**
  70950. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70951. */
  70952. path: AnimationChannelTargetPath;
  70953. }
  70954. /**
  70955. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70956. */
  70957. interface IAnimationSampler extends IProperty {
  70958. /**
  70959. * The index of an accessor containing keyframe input values, e.g., time
  70960. */
  70961. input: number;
  70962. /**
  70963. * Interpolation algorithm
  70964. */
  70965. interpolation?: AnimationSamplerInterpolation;
  70966. /**
  70967. * The index of an accessor, containing keyframe output values
  70968. */
  70969. output: number;
  70970. }
  70971. /**
  70972. * A keyframe animation
  70973. */
  70974. interface IAnimation extends IChildRootProperty {
  70975. /**
  70976. * An array of channels, each of which targets an animation's sampler at a node's property
  70977. */
  70978. channels: IAnimationChannel[];
  70979. /**
  70980. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70981. */
  70982. samplers: IAnimationSampler[];
  70983. }
  70984. /**
  70985. * Metadata about the glTF asset
  70986. */
  70987. interface IAsset extends IChildRootProperty {
  70988. /**
  70989. * A copyright message suitable for display to credit the content creator
  70990. */
  70991. copyright?: string;
  70992. /**
  70993. * Tool that generated this glTF model. Useful for debugging
  70994. */
  70995. generator?: string;
  70996. /**
  70997. * The glTF version that this asset targets
  70998. */
  70999. version: string;
  71000. /**
  71001. * The minimum glTF version that this asset targets
  71002. */
  71003. minVersion?: string;
  71004. }
  71005. /**
  71006. * A buffer points to binary geometry, animation, or skins
  71007. */
  71008. interface IBuffer extends IChildRootProperty {
  71009. /**
  71010. * 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
  71011. */
  71012. uri?: string;
  71013. /**
  71014. * The length of the buffer in bytes
  71015. */
  71016. byteLength: number;
  71017. }
  71018. /**
  71019. * A view into a buffer generally representing a subset of the buffer
  71020. */
  71021. interface IBufferView extends IChildRootProperty {
  71022. /**
  71023. * The index of the buffer
  71024. */
  71025. buffer: number;
  71026. /**
  71027. * The offset into the buffer in bytes
  71028. */
  71029. byteOffset?: number;
  71030. /**
  71031. * The lenth of the bufferView in bytes
  71032. */
  71033. byteLength: number;
  71034. /**
  71035. * The stride, in bytes
  71036. */
  71037. byteStride?: number;
  71038. }
  71039. /**
  71040. * An orthographic camera containing properties to create an orthographic projection matrix
  71041. */
  71042. interface ICameraOrthographic extends IProperty {
  71043. /**
  71044. * The floating-point horizontal magnification of the view. Must not be zero
  71045. */
  71046. xmag: number;
  71047. /**
  71048. * The floating-point vertical magnification of the view. Must not be zero
  71049. */
  71050. ymag: number;
  71051. /**
  71052. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  71053. */
  71054. zfar: number;
  71055. /**
  71056. * The floating-point distance to the near clipping plane
  71057. */
  71058. znear: number;
  71059. }
  71060. /**
  71061. * A perspective camera containing properties to create a perspective projection matrix
  71062. */
  71063. interface ICameraPerspective extends IProperty {
  71064. /**
  71065. * The floating-point aspect ratio of the field of view
  71066. */
  71067. aspectRatio?: number;
  71068. /**
  71069. * The floating-point vertical field of view in radians
  71070. */
  71071. yfov: number;
  71072. /**
  71073. * The floating-point distance to the far clipping plane
  71074. */
  71075. zfar?: number;
  71076. /**
  71077. * The floating-point distance to the near clipping plane
  71078. */
  71079. znear: number;
  71080. }
  71081. /**
  71082. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  71083. */
  71084. interface ICamera extends IChildRootProperty {
  71085. /**
  71086. * An orthographic camera containing properties to create an orthographic projection matrix
  71087. */
  71088. orthographic?: ICameraOrthographic;
  71089. /**
  71090. * A perspective camera containing properties to create a perspective projection matrix
  71091. */
  71092. perspective?: ICameraPerspective;
  71093. /**
  71094. * Specifies if the camera uses a perspective or orthographic projection
  71095. */
  71096. type: CameraType;
  71097. }
  71098. /**
  71099. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  71100. */
  71101. interface IImage extends IChildRootProperty {
  71102. /**
  71103. * 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
  71104. */
  71105. uri?: string;
  71106. /**
  71107. * The image's MIME type
  71108. */
  71109. mimeType?: ImageMimeType;
  71110. /**
  71111. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  71112. */
  71113. bufferView?: number;
  71114. }
  71115. /**
  71116. * Material Normal Texture Info
  71117. */
  71118. interface IMaterialNormalTextureInfo extends ITextureInfo {
  71119. /**
  71120. * The scalar multiplier applied to each normal vector of the normal texture
  71121. */
  71122. scale?: number;
  71123. }
  71124. /**
  71125. * Material Occlusion Texture Info
  71126. */
  71127. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  71128. /**
  71129. * A scalar multiplier controlling the amount of occlusion applied
  71130. */
  71131. strength?: number;
  71132. }
  71133. /**
  71134. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  71135. */
  71136. interface IMaterialPbrMetallicRoughness {
  71137. /**
  71138. * The material's base color factor
  71139. */
  71140. baseColorFactor?: number[];
  71141. /**
  71142. * The base color texture
  71143. */
  71144. baseColorTexture?: ITextureInfo;
  71145. /**
  71146. * The metalness of the material
  71147. */
  71148. metallicFactor?: number;
  71149. /**
  71150. * The roughness of the material
  71151. */
  71152. roughnessFactor?: number;
  71153. /**
  71154. * The metallic-roughness texture
  71155. */
  71156. metallicRoughnessTexture?: ITextureInfo;
  71157. }
  71158. /**
  71159. * The material appearance of a primitive
  71160. */
  71161. interface IMaterial extends IChildRootProperty {
  71162. /**
  71163. * 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
  71164. */
  71165. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  71166. /**
  71167. * The normal map texture
  71168. */
  71169. normalTexture?: IMaterialNormalTextureInfo;
  71170. /**
  71171. * The occlusion map texture
  71172. */
  71173. occlusionTexture?: IMaterialOcclusionTextureInfo;
  71174. /**
  71175. * The emissive map texture
  71176. */
  71177. emissiveTexture?: ITextureInfo;
  71178. /**
  71179. * 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
  71180. */
  71181. emissiveFactor?: number[];
  71182. /**
  71183. * The alpha rendering mode of the material
  71184. */
  71185. alphaMode?: MaterialAlphaMode;
  71186. /**
  71187. * The alpha cutoff value of the material
  71188. */
  71189. alphaCutoff?: number;
  71190. /**
  71191. * Specifies whether the material is double sided
  71192. */
  71193. doubleSided?: boolean;
  71194. }
  71195. /**
  71196. * Geometry to be rendered with the given material
  71197. */
  71198. interface IMeshPrimitive extends IProperty {
  71199. /**
  71200. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  71201. */
  71202. attributes: {
  71203. [name: string]: number;
  71204. };
  71205. /**
  71206. * The index of the accessor that contains the indices
  71207. */
  71208. indices?: number;
  71209. /**
  71210. * The index of the material to apply to this primitive when rendering
  71211. */
  71212. material?: number;
  71213. /**
  71214. * The type of primitives to render. All valid values correspond to WebGL enums
  71215. */
  71216. mode?: MeshPrimitiveMode;
  71217. /**
  71218. * 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
  71219. */
  71220. targets?: {
  71221. [name: string]: number;
  71222. }[];
  71223. }
  71224. /**
  71225. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  71226. */
  71227. interface IMesh extends IChildRootProperty {
  71228. /**
  71229. * An array of primitives, each defining geometry to be rendered with a material
  71230. */
  71231. primitives: IMeshPrimitive[];
  71232. /**
  71233. * Array of weights to be applied to the Morph Targets
  71234. */
  71235. weights?: number[];
  71236. }
  71237. /**
  71238. * A node in the node hierarchy
  71239. */
  71240. interface INode extends IChildRootProperty {
  71241. /**
  71242. * The index of the camera referenced by this node
  71243. */
  71244. camera?: number;
  71245. /**
  71246. * The indices of this node's children
  71247. */
  71248. children?: number[];
  71249. /**
  71250. * The index of the skin referenced by this node
  71251. */
  71252. skin?: number;
  71253. /**
  71254. * A floating-point 4x4 transformation matrix stored in column-major order
  71255. */
  71256. matrix?: number[];
  71257. /**
  71258. * The index of the mesh in this node
  71259. */
  71260. mesh?: number;
  71261. /**
  71262. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  71263. */
  71264. rotation?: number[];
  71265. /**
  71266. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  71267. */
  71268. scale?: number[];
  71269. /**
  71270. * The node's translation along the x, y, and z axes
  71271. */
  71272. translation?: number[];
  71273. /**
  71274. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  71275. */
  71276. weights?: number[];
  71277. }
  71278. /**
  71279. * Texture sampler properties for filtering and wrapping modes
  71280. */
  71281. interface ISampler extends IChildRootProperty {
  71282. /**
  71283. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  71284. */
  71285. magFilter?: TextureMagFilter;
  71286. /**
  71287. * Minification filter. All valid values correspond to WebGL enums
  71288. */
  71289. minFilter?: TextureMinFilter;
  71290. /**
  71291. * S (U) wrapping mode. All valid values correspond to WebGL enums
  71292. */
  71293. wrapS?: TextureWrapMode;
  71294. /**
  71295. * T (V) wrapping mode. All valid values correspond to WebGL enums
  71296. */
  71297. wrapT?: TextureWrapMode;
  71298. }
  71299. /**
  71300. * The root nodes of a scene
  71301. */
  71302. interface IScene extends IChildRootProperty {
  71303. /**
  71304. * The indices of each root node
  71305. */
  71306. nodes: number[];
  71307. }
  71308. /**
  71309. * Joints and matrices defining a skin
  71310. */
  71311. interface ISkin extends IChildRootProperty {
  71312. /**
  71313. * 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
  71314. */
  71315. inverseBindMatrices?: number;
  71316. /**
  71317. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  71318. */
  71319. skeleton?: number;
  71320. /**
  71321. * 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)
  71322. */
  71323. joints: number[];
  71324. }
  71325. /**
  71326. * A texture and its sampler
  71327. */
  71328. interface ITexture extends IChildRootProperty {
  71329. /**
  71330. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  71331. */
  71332. sampler?: number;
  71333. /**
  71334. * The index of the image used by this texture
  71335. */
  71336. source: number;
  71337. }
  71338. /**
  71339. * Reference to a texture
  71340. */
  71341. interface ITextureInfo extends IProperty {
  71342. /**
  71343. * The index of the texture
  71344. */
  71345. index: number;
  71346. /**
  71347. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  71348. */
  71349. texCoord?: number;
  71350. }
  71351. /**
  71352. * The root object for a glTF asset
  71353. */
  71354. interface IGLTF extends IProperty {
  71355. /**
  71356. * An array of accessors. An accessor is a typed view into a bufferView
  71357. */
  71358. accessors?: IAccessor[];
  71359. /**
  71360. * An array of keyframe animations
  71361. */
  71362. animations?: IAnimation[];
  71363. /**
  71364. * Metadata about the glTF asset
  71365. */
  71366. asset: IAsset;
  71367. /**
  71368. * An array of buffers. A buffer points to binary geometry, animation, or skins
  71369. */
  71370. buffers?: IBuffer[];
  71371. /**
  71372. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  71373. */
  71374. bufferViews?: IBufferView[];
  71375. /**
  71376. * An array of cameras
  71377. */
  71378. cameras?: ICamera[];
  71379. /**
  71380. * Names of glTF extensions used somewhere in this asset
  71381. */
  71382. extensionsUsed?: string[];
  71383. /**
  71384. * Names of glTF extensions required to properly load this asset
  71385. */
  71386. extensionsRequired?: string[];
  71387. /**
  71388. * An array of images. An image defines data used to create a texture
  71389. */
  71390. images?: IImage[];
  71391. /**
  71392. * An array of materials. A material defines the appearance of a primitive
  71393. */
  71394. materials?: IMaterial[];
  71395. /**
  71396. * An array of meshes. A mesh is a set of primitives to be rendered
  71397. */
  71398. meshes?: IMesh[];
  71399. /**
  71400. * An array of nodes
  71401. */
  71402. nodes?: INode[];
  71403. /**
  71404. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  71405. */
  71406. samplers?: ISampler[];
  71407. /**
  71408. * The index of the default scene
  71409. */
  71410. scene?: number;
  71411. /**
  71412. * An array of scenes
  71413. */
  71414. scenes?: IScene[];
  71415. /**
  71416. * An array of skins. A skin is defined by joints and matrices
  71417. */
  71418. skins?: ISkin[];
  71419. /**
  71420. * An array of textures
  71421. */
  71422. textures?: ITexture[];
  71423. }
  71424. /**
  71425. * The glTF validation results
  71426. * @ignore
  71427. */
  71428. interface IGLTFValidationResults {
  71429. info: {
  71430. generator: string;
  71431. hasAnimations: boolean;
  71432. hasDefaultScene: boolean;
  71433. hasMaterials: boolean;
  71434. hasMorphTargets: boolean;
  71435. hasSkins: boolean;
  71436. hasTextures: boolean;
  71437. maxAttributesUsed: number;
  71438. primitivesCount: number
  71439. };
  71440. issues: {
  71441. messages: Array<string>;
  71442. numErrors: number;
  71443. numHints: number;
  71444. numInfos: number;
  71445. numWarnings: number;
  71446. truncated: boolean
  71447. };
  71448. mimeType: string;
  71449. uri: string;
  71450. validatedAt: string;
  71451. validatorVersion: string;
  71452. }
  71453. /**
  71454. * The glTF validation options
  71455. */
  71456. interface IGLTFValidationOptions {
  71457. /** Uri to use */
  71458. uri?: string;
  71459. /** Function used to load external resources */
  71460. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  71461. /** Boolean indicating that we need to validate accessor data */
  71462. validateAccessorData?: boolean;
  71463. /** max number of issues allowed */
  71464. maxIssues?: number;
  71465. /** Ignored issues */
  71466. ignoredIssues?: Array<string>;
  71467. /** Value to override severy settings */
  71468. severityOverrides?: Object;
  71469. }
  71470. /**
  71471. * The glTF validator object
  71472. * @ignore
  71473. */
  71474. interface IGLTFValidator {
  71475. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71476. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71477. }
  71478. }
  71479. declare module BABYLON {
  71480. /** @hidden */
  71481. export var cellPixelShader: {
  71482. name: string;
  71483. shader: string;
  71484. };
  71485. }
  71486. declare module BABYLON {
  71487. /** @hidden */
  71488. export var cellVertexShader: {
  71489. name: string;
  71490. shader: string;
  71491. };
  71492. }
  71493. declare module BABYLON {
  71494. export class CellMaterial extends BABYLON.PushMaterial {
  71495. private _diffuseTexture;
  71496. diffuseTexture: BABYLON.BaseTexture;
  71497. diffuseColor: BABYLON.Color3;
  71498. _computeHighLevel: boolean;
  71499. computeHighLevel: boolean;
  71500. private _disableLighting;
  71501. disableLighting: boolean;
  71502. private _maxSimultaneousLights;
  71503. maxSimultaneousLights: number;
  71504. private _renderId;
  71505. constructor(name: string, scene: BABYLON.Scene);
  71506. needAlphaBlending(): boolean;
  71507. needAlphaTesting(): boolean;
  71508. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71509. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71510. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71511. getAnimatables(): BABYLON.IAnimatable[];
  71512. getActiveTextures(): BABYLON.BaseTexture[];
  71513. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71514. dispose(forceDisposeEffect?: boolean): void;
  71515. getClassName(): string;
  71516. clone(name: string): CellMaterial;
  71517. serialize(): any;
  71518. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  71519. }
  71520. }
  71521. declare module BABYLON {
  71522. export class CustomShaderStructure {
  71523. FragmentStore: string;
  71524. VertexStore: string;
  71525. constructor();
  71526. }
  71527. export class ShaderSpecialParts {
  71528. constructor();
  71529. Fragment_Begin: string;
  71530. Fragment_Definitions: string;
  71531. Fragment_MainBegin: string;
  71532. Fragment_Custom_Diffuse: string;
  71533. Fragment_Before_Lights: string;
  71534. Fragment_Before_Fog: string;
  71535. Fragment_Custom_Alpha: string;
  71536. Fragment_Before_FragColor: string;
  71537. Vertex_Begin: string;
  71538. Vertex_Definitions: string;
  71539. Vertex_MainBegin: string;
  71540. Vertex_Before_PositionUpdated: string;
  71541. Vertex_Before_NormalUpdated: string;
  71542. Vertex_MainEnd: string;
  71543. }
  71544. export class CustomMaterial extends BABYLON.StandardMaterial {
  71545. static ShaderIndexer: number;
  71546. CustomParts: ShaderSpecialParts;
  71547. _isCreatedShader: boolean;
  71548. _createdShaderName: string;
  71549. _customUniform: string[];
  71550. _newUniforms: string[];
  71551. _newUniformInstances: any[];
  71552. _newSamplerInstances: BABYLON.Texture[];
  71553. FragmentShader: string;
  71554. VertexShader: string;
  71555. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71556. ReviewUniform(name: string, arr: string[]): string[];
  71557. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  71558. constructor(name: string, scene: BABYLON.Scene);
  71559. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  71560. Fragment_Begin(shaderPart: string): CustomMaterial;
  71561. Fragment_Definitions(shaderPart: string): CustomMaterial;
  71562. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  71563. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  71564. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  71565. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  71566. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  71567. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  71568. Vertex_Begin(shaderPart: string): CustomMaterial;
  71569. Vertex_Definitions(shaderPart: string): CustomMaterial;
  71570. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  71571. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  71572. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  71573. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  71574. }
  71575. }
  71576. declare module BABYLON {
  71577. export class ShaderAlebdoParts {
  71578. constructor();
  71579. Fragment_Begin: string;
  71580. Fragment_Definitions: string;
  71581. Fragment_MainBegin: string;
  71582. Fragment_Custom_Albedo: string;
  71583. Fragment_Before_Lights: string;
  71584. Fragment_Custom_MetallicRoughness: string;
  71585. Fragment_Custom_MicroSurface: string;
  71586. Fragment_Before_Fog: string;
  71587. Fragment_Custom_Alpha: string;
  71588. Fragment_Before_FragColor: string;
  71589. Vertex_Begin: string;
  71590. Vertex_Definitions: string;
  71591. Vertex_MainBegin: string;
  71592. Vertex_Before_PositionUpdated: string;
  71593. Vertex_Before_NormalUpdated: string;
  71594. Vertex_MainEnd: string;
  71595. }
  71596. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  71597. static ShaderIndexer: number;
  71598. CustomParts: ShaderAlebdoParts;
  71599. _isCreatedShader: boolean;
  71600. _createdShaderName: string;
  71601. _customUniform: string[];
  71602. _newUniforms: string[];
  71603. _newUniformInstances: any[];
  71604. _newSamplerInstances: BABYLON.Texture[];
  71605. FragmentShader: string;
  71606. VertexShader: string;
  71607. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71608. ReviewUniform(name: string, arr: string[]): string[];
  71609. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  71610. constructor(name: string, scene: BABYLON.Scene);
  71611. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  71612. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  71613. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  71614. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  71615. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  71616. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  71617. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  71618. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  71619. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  71620. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  71621. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  71622. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  71623. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  71624. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  71625. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  71626. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  71627. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  71628. }
  71629. }
  71630. declare module BABYLON {
  71631. /** @hidden */
  71632. export var firePixelShader: {
  71633. name: string;
  71634. shader: string;
  71635. };
  71636. }
  71637. declare module BABYLON {
  71638. /** @hidden */
  71639. export var fireVertexShader: {
  71640. name: string;
  71641. shader: string;
  71642. };
  71643. }
  71644. declare module BABYLON {
  71645. export class FireMaterial extends BABYLON.PushMaterial {
  71646. private _diffuseTexture;
  71647. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71648. private _distortionTexture;
  71649. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71650. private _opacityTexture;
  71651. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71652. diffuseColor: BABYLON.Color3;
  71653. speed: number;
  71654. private _scaledDiffuse;
  71655. private _renderId;
  71656. private _lastTime;
  71657. constructor(name: string, scene: BABYLON.Scene);
  71658. needAlphaBlending(): boolean;
  71659. needAlphaTesting(): boolean;
  71660. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71661. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71662. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71663. getAnimatables(): BABYLON.IAnimatable[];
  71664. getActiveTextures(): BABYLON.BaseTexture[];
  71665. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71666. getClassName(): string;
  71667. dispose(forceDisposeEffect?: boolean): void;
  71668. clone(name: string): FireMaterial;
  71669. serialize(): any;
  71670. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  71671. }
  71672. }
  71673. declare module BABYLON {
  71674. /** @hidden */
  71675. export var furPixelShader: {
  71676. name: string;
  71677. shader: string;
  71678. };
  71679. }
  71680. declare module BABYLON {
  71681. /** @hidden */
  71682. export var furVertexShader: {
  71683. name: string;
  71684. shader: string;
  71685. };
  71686. }
  71687. declare module BABYLON {
  71688. export class FurMaterial extends BABYLON.PushMaterial {
  71689. private _diffuseTexture;
  71690. diffuseTexture: BABYLON.BaseTexture;
  71691. private _heightTexture;
  71692. heightTexture: BABYLON.BaseTexture;
  71693. diffuseColor: BABYLON.Color3;
  71694. furLength: number;
  71695. furAngle: number;
  71696. furColor: BABYLON.Color3;
  71697. furOffset: number;
  71698. furSpacing: number;
  71699. furGravity: BABYLON.Vector3;
  71700. furSpeed: number;
  71701. furDensity: number;
  71702. furOcclusion: number;
  71703. furTexture: BABYLON.DynamicTexture;
  71704. private _disableLighting;
  71705. disableLighting: boolean;
  71706. private _maxSimultaneousLights;
  71707. maxSimultaneousLights: number;
  71708. highLevelFur: boolean;
  71709. _meshes: BABYLON.AbstractMesh[];
  71710. private _renderId;
  71711. private _furTime;
  71712. constructor(name: string, scene: BABYLON.Scene);
  71713. furTime: number;
  71714. needAlphaBlending(): boolean;
  71715. needAlphaTesting(): boolean;
  71716. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71717. updateFur(): void;
  71718. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71719. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71720. getAnimatables(): BABYLON.IAnimatable[];
  71721. getActiveTextures(): BABYLON.BaseTexture[];
  71722. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71723. dispose(forceDisposeEffect?: boolean): void;
  71724. clone(name: string): FurMaterial;
  71725. serialize(): any;
  71726. getClassName(): string;
  71727. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  71728. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  71729. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  71730. }
  71731. }
  71732. declare module BABYLON {
  71733. /** @hidden */
  71734. export var gradientPixelShader: {
  71735. name: string;
  71736. shader: string;
  71737. };
  71738. }
  71739. declare module BABYLON {
  71740. /** @hidden */
  71741. export var gradientVertexShader: {
  71742. name: string;
  71743. shader: string;
  71744. };
  71745. }
  71746. declare module BABYLON {
  71747. export class GradientMaterial extends BABYLON.PushMaterial {
  71748. private _maxSimultaneousLights;
  71749. maxSimultaneousLights: number;
  71750. topColor: BABYLON.Color3;
  71751. topColorAlpha: number;
  71752. bottomColor: BABYLON.Color3;
  71753. bottomColorAlpha: number;
  71754. offset: number;
  71755. scale: number;
  71756. smoothness: number;
  71757. private _disableLighting;
  71758. disableLighting: boolean;
  71759. private _renderId;
  71760. constructor(name: string, scene: BABYLON.Scene);
  71761. needAlphaBlending(): boolean;
  71762. needAlphaTesting(): boolean;
  71763. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71764. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71765. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71766. getAnimatables(): BABYLON.IAnimatable[];
  71767. dispose(forceDisposeEffect?: boolean): void;
  71768. clone(name: string): GradientMaterial;
  71769. serialize(): any;
  71770. getClassName(): string;
  71771. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  71772. }
  71773. }
  71774. declare module BABYLON {
  71775. /** @hidden */
  71776. export var gridPixelShader: {
  71777. name: string;
  71778. shader: string;
  71779. };
  71780. }
  71781. declare module BABYLON {
  71782. /** @hidden */
  71783. export var gridVertexShader: {
  71784. name: string;
  71785. shader: string;
  71786. };
  71787. }
  71788. declare module BABYLON {
  71789. /**
  71790. * The grid materials allows you to wrap any shape with a grid.
  71791. * Colors are customizable.
  71792. */
  71793. export class GridMaterial extends BABYLON.PushMaterial {
  71794. /**
  71795. * Main color of the grid (e.g. between lines)
  71796. */
  71797. mainColor: BABYLON.Color3;
  71798. /**
  71799. * Color of the grid lines.
  71800. */
  71801. lineColor: BABYLON.Color3;
  71802. /**
  71803. * The scale of the grid compared to unit.
  71804. */
  71805. gridRatio: number;
  71806. /**
  71807. * Allows setting an offset for the grid lines.
  71808. */
  71809. gridOffset: BABYLON.Vector3;
  71810. /**
  71811. * The frequency of thicker lines.
  71812. */
  71813. majorUnitFrequency: number;
  71814. /**
  71815. * The visibility of minor units in the grid.
  71816. */
  71817. minorUnitVisibility: number;
  71818. /**
  71819. * The grid opacity outside of the lines.
  71820. */
  71821. opacity: number;
  71822. /**
  71823. * Determine RBG output is premultiplied by alpha value.
  71824. */
  71825. preMultiplyAlpha: boolean;
  71826. private _opacityTexture;
  71827. opacityTexture: BABYLON.BaseTexture;
  71828. private _gridControl;
  71829. private _renderId;
  71830. /**
  71831. * constructor
  71832. * @param name The name given to the material in order to identify it afterwards.
  71833. * @param scene The scene the material is used in.
  71834. */
  71835. constructor(name: string, scene: BABYLON.Scene);
  71836. /**
  71837. * Returns wehter or not the grid requires alpha blending.
  71838. */
  71839. needAlphaBlending(): boolean;
  71840. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71841. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71842. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71843. /**
  71844. * Dispose the material and its associated resources.
  71845. * @param forceDisposeEffect will also dispose the used effect when true
  71846. */
  71847. dispose(forceDisposeEffect?: boolean): void;
  71848. clone(name: string): GridMaterial;
  71849. serialize(): any;
  71850. getClassName(): string;
  71851. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  71852. }
  71853. }
  71854. declare module BABYLON {
  71855. /** @hidden */
  71856. export var lavaPixelShader: {
  71857. name: string;
  71858. shader: string;
  71859. };
  71860. }
  71861. declare module BABYLON {
  71862. /** @hidden */
  71863. export var lavaVertexShader: {
  71864. name: string;
  71865. shader: string;
  71866. };
  71867. }
  71868. declare module BABYLON {
  71869. export class LavaMaterial extends BABYLON.PushMaterial {
  71870. private _diffuseTexture;
  71871. diffuseTexture: BABYLON.BaseTexture;
  71872. noiseTexture: BABYLON.BaseTexture;
  71873. fogColor: BABYLON.Color3;
  71874. speed: number;
  71875. movingSpeed: number;
  71876. lowFrequencySpeed: number;
  71877. fogDensity: number;
  71878. private _lastTime;
  71879. diffuseColor: BABYLON.Color3;
  71880. private _disableLighting;
  71881. disableLighting: boolean;
  71882. private _unlit;
  71883. unlit: boolean;
  71884. private _maxSimultaneousLights;
  71885. maxSimultaneousLights: number;
  71886. private _scaledDiffuse;
  71887. private _renderId;
  71888. constructor(name: string, scene: BABYLON.Scene);
  71889. needAlphaBlending(): boolean;
  71890. needAlphaTesting(): boolean;
  71891. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71892. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71893. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71894. getAnimatables(): BABYLON.IAnimatable[];
  71895. getActiveTextures(): BABYLON.BaseTexture[];
  71896. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71897. dispose(forceDisposeEffect?: boolean): void;
  71898. clone(name: string): LavaMaterial;
  71899. serialize(): any;
  71900. getClassName(): string;
  71901. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  71902. }
  71903. }
  71904. declare module BABYLON {
  71905. /** @hidden */
  71906. export var mixPixelShader: {
  71907. name: string;
  71908. shader: string;
  71909. };
  71910. }
  71911. declare module BABYLON {
  71912. /** @hidden */
  71913. export var mixVertexShader: {
  71914. name: string;
  71915. shader: string;
  71916. };
  71917. }
  71918. declare module BABYLON {
  71919. export class MixMaterial extends BABYLON.PushMaterial {
  71920. /**
  71921. * Mix textures
  71922. */
  71923. private _mixTexture1;
  71924. mixTexture1: BABYLON.BaseTexture;
  71925. private _mixTexture2;
  71926. mixTexture2: BABYLON.BaseTexture;
  71927. /**
  71928. * Diffuse textures
  71929. */
  71930. private _diffuseTexture1;
  71931. diffuseTexture1: BABYLON.Texture;
  71932. private _diffuseTexture2;
  71933. diffuseTexture2: BABYLON.Texture;
  71934. private _diffuseTexture3;
  71935. diffuseTexture3: BABYLON.Texture;
  71936. private _diffuseTexture4;
  71937. diffuseTexture4: BABYLON.Texture;
  71938. private _diffuseTexture5;
  71939. diffuseTexture5: BABYLON.Texture;
  71940. private _diffuseTexture6;
  71941. diffuseTexture6: BABYLON.Texture;
  71942. private _diffuseTexture7;
  71943. diffuseTexture7: BABYLON.Texture;
  71944. private _diffuseTexture8;
  71945. diffuseTexture8: BABYLON.Texture;
  71946. /**
  71947. * Uniforms
  71948. */
  71949. diffuseColor: BABYLON.Color3;
  71950. specularColor: BABYLON.Color3;
  71951. specularPower: number;
  71952. private _disableLighting;
  71953. disableLighting: boolean;
  71954. private _maxSimultaneousLights;
  71955. maxSimultaneousLights: number;
  71956. private _renderId;
  71957. constructor(name: string, scene: BABYLON.Scene);
  71958. needAlphaBlending(): boolean;
  71959. needAlphaTesting(): boolean;
  71960. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71961. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71962. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71963. getAnimatables(): BABYLON.IAnimatable[];
  71964. getActiveTextures(): BABYLON.BaseTexture[];
  71965. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71966. dispose(forceDisposeEffect?: boolean): void;
  71967. clone(name: string): MixMaterial;
  71968. serialize(): any;
  71969. getClassName(): string;
  71970. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  71971. }
  71972. }
  71973. declare module BABYLON {
  71974. /** @hidden */
  71975. export var normalPixelShader: {
  71976. name: string;
  71977. shader: string;
  71978. };
  71979. }
  71980. declare module BABYLON {
  71981. /** @hidden */
  71982. export var normalVertexShader: {
  71983. name: string;
  71984. shader: string;
  71985. };
  71986. }
  71987. declare module BABYLON {
  71988. export class NormalMaterial extends BABYLON.PushMaterial {
  71989. private _diffuseTexture;
  71990. diffuseTexture: BABYLON.BaseTexture;
  71991. diffuseColor: BABYLON.Color3;
  71992. private _disableLighting;
  71993. disableLighting: boolean;
  71994. private _maxSimultaneousLights;
  71995. maxSimultaneousLights: number;
  71996. private _renderId;
  71997. constructor(name: string, scene: BABYLON.Scene);
  71998. needAlphaBlending(): boolean;
  71999. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  72000. needAlphaTesting(): boolean;
  72001. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72002. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72003. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72004. getAnimatables(): BABYLON.IAnimatable[];
  72005. getActiveTextures(): BABYLON.BaseTexture[];
  72006. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72007. dispose(forceDisposeEffect?: boolean): void;
  72008. clone(name: string): NormalMaterial;
  72009. serialize(): any;
  72010. getClassName(): string;
  72011. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  72012. }
  72013. }
  72014. declare module BABYLON {
  72015. /** @hidden */
  72016. export var shadowOnlyPixelShader: {
  72017. name: string;
  72018. shader: string;
  72019. };
  72020. }
  72021. declare module BABYLON {
  72022. /** @hidden */
  72023. export var shadowOnlyVertexShader: {
  72024. name: string;
  72025. shader: string;
  72026. };
  72027. }
  72028. declare module BABYLON {
  72029. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  72030. private _renderId;
  72031. private _activeLight;
  72032. constructor(name: string, scene: BABYLON.Scene);
  72033. shadowColor: BABYLON.Color3;
  72034. needAlphaBlending(): boolean;
  72035. needAlphaTesting(): boolean;
  72036. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72037. activeLight: BABYLON.IShadowLight;
  72038. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72039. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72040. clone(name: string): ShadowOnlyMaterial;
  72041. serialize(): any;
  72042. getClassName(): string;
  72043. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  72044. }
  72045. }
  72046. declare module BABYLON {
  72047. /** @hidden */
  72048. export var simplePixelShader: {
  72049. name: string;
  72050. shader: string;
  72051. };
  72052. }
  72053. declare module BABYLON {
  72054. /** @hidden */
  72055. export var simpleVertexShader: {
  72056. name: string;
  72057. shader: string;
  72058. };
  72059. }
  72060. declare module BABYLON {
  72061. export class SimpleMaterial extends BABYLON.PushMaterial {
  72062. private _diffuseTexture;
  72063. diffuseTexture: BABYLON.BaseTexture;
  72064. diffuseColor: BABYLON.Color3;
  72065. private _disableLighting;
  72066. disableLighting: boolean;
  72067. private _maxSimultaneousLights;
  72068. maxSimultaneousLights: number;
  72069. private _renderId;
  72070. constructor(name: string, scene: BABYLON.Scene);
  72071. needAlphaBlending(): boolean;
  72072. needAlphaTesting(): boolean;
  72073. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72074. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72075. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72076. getAnimatables(): BABYLON.IAnimatable[];
  72077. getActiveTextures(): BABYLON.BaseTexture[];
  72078. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72079. dispose(forceDisposeEffect?: boolean): void;
  72080. clone(name: string): SimpleMaterial;
  72081. serialize(): any;
  72082. getClassName(): string;
  72083. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  72084. }
  72085. }
  72086. declare module BABYLON {
  72087. /** @hidden */
  72088. export var skyPixelShader: {
  72089. name: string;
  72090. shader: string;
  72091. };
  72092. }
  72093. declare module BABYLON {
  72094. /** @hidden */
  72095. export var skyVertexShader: {
  72096. name: string;
  72097. shader: string;
  72098. };
  72099. }
  72100. declare module BABYLON {
  72101. /**
  72102. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  72103. * @see https://doc.babylonjs.com/extensions/sky
  72104. */
  72105. export class SkyMaterial extends BABYLON.PushMaterial {
  72106. /**
  72107. * Defines the overall luminance of sky in interval ]0, 1[.
  72108. */
  72109. luminance: number;
  72110. /**
  72111. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  72112. */
  72113. turbidity: number;
  72114. /**
  72115. * Defines the sky appearance (light intensity).
  72116. */
  72117. rayleigh: number;
  72118. /**
  72119. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  72120. */
  72121. mieCoefficient: number;
  72122. /**
  72123. * Defines the amount of haze particles following the Mie scattering theory.
  72124. */
  72125. mieDirectionalG: number;
  72126. /**
  72127. * Defines the distance of the sun according to the active scene camera.
  72128. */
  72129. distance: number;
  72130. /**
  72131. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  72132. * "inclined".
  72133. */
  72134. inclination: number;
  72135. /**
  72136. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  72137. * an object direction and a reference direction.
  72138. */
  72139. azimuth: number;
  72140. /**
  72141. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  72142. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  72143. */
  72144. sunPosition: BABYLON.Vector3;
  72145. /**
  72146. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  72147. * .sunPosition property.
  72148. */
  72149. useSunPosition: boolean;
  72150. /**
  72151. * Defines an offset vector used to get a horizon offset.
  72152. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  72153. */
  72154. cameraOffset: BABYLON.Vector3;
  72155. private _cameraPosition;
  72156. private _renderId;
  72157. /**
  72158. * Instantiates a new sky material.
  72159. * This material allows to create dynamic and texture free
  72160. * effects for skyboxes by taking care of the atmosphere state.
  72161. * @see https://doc.babylonjs.com/extensions/sky
  72162. * @param name Define the name of the material in the scene
  72163. * @param scene Define the scene the material belong to
  72164. */
  72165. constructor(name: string, scene: BABYLON.Scene);
  72166. /**
  72167. * Specifies if the material will require alpha blending
  72168. * @returns a boolean specifying if alpha blending is needed
  72169. */
  72170. needAlphaBlending(): boolean;
  72171. /**
  72172. * Specifies if this material should be rendered in alpha test mode
  72173. * @returns false as the sky material doesn't need alpha testing.
  72174. */
  72175. needAlphaTesting(): boolean;
  72176. /**
  72177. * Get the texture used for alpha test purpose.
  72178. * @returns null as the sky material has no texture.
  72179. */
  72180. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72181. /**
  72182. * Get if the submesh is ready to be used and all its information available.
  72183. * Child classes can use it to update shaders
  72184. * @param mesh defines the mesh to check
  72185. * @param subMesh defines which submesh to check
  72186. * @param useInstances specifies that instances should be used
  72187. * @returns a boolean indicating that the submesh is ready or not
  72188. */
  72189. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72190. /**
  72191. * Binds the submesh to this material by preparing the effect and shader to draw
  72192. * @param world defines the world transformation matrix
  72193. * @param mesh defines the mesh containing the submesh
  72194. * @param subMesh defines the submesh to bind the material to
  72195. */
  72196. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72197. /**
  72198. * Get the list of animatables in the material.
  72199. * @returns the list of animatables object used in the material
  72200. */
  72201. getAnimatables(): BABYLON.IAnimatable[];
  72202. /**
  72203. * Disposes the material
  72204. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  72205. */
  72206. dispose(forceDisposeEffect?: boolean): void;
  72207. /**
  72208. * Makes a duplicate of the material, and gives it a new name
  72209. * @param name defines the new name for the duplicated material
  72210. * @returns the cloned material
  72211. */
  72212. clone(name: string): SkyMaterial;
  72213. /**
  72214. * Serializes this material in a JSON representation
  72215. * @returns the serialized material object
  72216. */
  72217. serialize(): any;
  72218. /**
  72219. * Gets the current class name of the material e.g. "SkyMaterial"
  72220. * Mainly use in serialization.
  72221. * @returns the class name
  72222. */
  72223. getClassName(): string;
  72224. /**
  72225. * Creates a sky material from parsed material data
  72226. * @param source defines the JSON representation of the material
  72227. * @param scene defines the hosting scene
  72228. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72229. * @returns a new sky material
  72230. */
  72231. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  72232. }
  72233. }
  72234. declare module BABYLON {
  72235. /** @hidden */
  72236. export var terrainPixelShader: {
  72237. name: string;
  72238. shader: string;
  72239. };
  72240. }
  72241. declare module BABYLON {
  72242. /** @hidden */
  72243. export var terrainVertexShader: {
  72244. name: string;
  72245. shader: string;
  72246. };
  72247. }
  72248. declare module BABYLON {
  72249. export class TerrainMaterial extends BABYLON.PushMaterial {
  72250. private _mixTexture;
  72251. mixTexture: BABYLON.BaseTexture;
  72252. private _diffuseTexture1;
  72253. diffuseTexture1: BABYLON.Texture;
  72254. private _diffuseTexture2;
  72255. diffuseTexture2: BABYLON.Texture;
  72256. private _diffuseTexture3;
  72257. diffuseTexture3: BABYLON.Texture;
  72258. private _bumpTexture1;
  72259. bumpTexture1: BABYLON.Texture;
  72260. private _bumpTexture2;
  72261. bumpTexture2: BABYLON.Texture;
  72262. private _bumpTexture3;
  72263. bumpTexture3: BABYLON.Texture;
  72264. diffuseColor: BABYLON.Color3;
  72265. specularColor: BABYLON.Color3;
  72266. specularPower: number;
  72267. private _disableLighting;
  72268. disableLighting: boolean;
  72269. private _maxSimultaneousLights;
  72270. maxSimultaneousLights: number;
  72271. private _renderId;
  72272. constructor(name: string, scene: BABYLON.Scene);
  72273. needAlphaBlending(): boolean;
  72274. needAlphaTesting(): boolean;
  72275. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72276. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72277. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72278. getAnimatables(): BABYLON.IAnimatable[];
  72279. getActiveTextures(): BABYLON.BaseTexture[];
  72280. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72281. dispose(forceDisposeEffect?: boolean): void;
  72282. clone(name: string): TerrainMaterial;
  72283. serialize(): any;
  72284. getClassName(): string;
  72285. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  72286. }
  72287. }
  72288. declare module BABYLON {
  72289. /** @hidden */
  72290. export var triplanarPixelShader: {
  72291. name: string;
  72292. shader: string;
  72293. };
  72294. }
  72295. declare module BABYLON {
  72296. /** @hidden */
  72297. export var triplanarVertexShader: {
  72298. name: string;
  72299. shader: string;
  72300. };
  72301. }
  72302. declare module BABYLON {
  72303. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  72304. mixTexture: BABYLON.BaseTexture;
  72305. private _diffuseTextureX;
  72306. diffuseTextureX: BABYLON.BaseTexture;
  72307. private _diffuseTextureY;
  72308. diffuseTextureY: BABYLON.BaseTexture;
  72309. private _diffuseTextureZ;
  72310. diffuseTextureZ: BABYLON.BaseTexture;
  72311. private _normalTextureX;
  72312. normalTextureX: BABYLON.BaseTexture;
  72313. private _normalTextureY;
  72314. normalTextureY: BABYLON.BaseTexture;
  72315. private _normalTextureZ;
  72316. normalTextureZ: BABYLON.BaseTexture;
  72317. tileSize: number;
  72318. diffuseColor: BABYLON.Color3;
  72319. specularColor: BABYLON.Color3;
  72320. specularPower: number;
  72321. private _disableLighting;
  72322. disableLighting: boolean;
  72323. private _maxSimultaneousLights;
  72324. maxSimultaneousLights: number;
  72325. private _renderId;
  72326. constructor(name: string, scene: BABYLON.Scene);
  72327. needAlphaBlending(): boolean;
  72328. needAlphaTesting(): boolean;
  72329. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72330. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72331. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72332. getAnimatables(): BABYLON.IAnimatable[];
  72333. getActiveTextures(): BABYLON.BaseTexture[];
  72334. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72335. dispose(forceDisposeEffect?: boolean): void;
  72336. clone(name: string): TriPlanarMaterial;
  72337. serialize(): any;
  72338. getClassName(): string;
  72339. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  72340. }
  72341. }
  72342. declare module BABYLON {
  72343. /** @hidden */
  72344. export var waterPixelShader: {
  72345. name: string;
  72346. shader: string;
  72347. };
  72348. }
  72349. declare module BABYLON {
  72350. /** @hidden */
  72351. export var waterVertexShader: {
  72352. name: string;
  72353. shader: string;
  72354. };
  72355. }
  72356. declare module BABYLON {
  72357. export class WaterMaterial extends BABYLON.PushMaterial {
  72358. renderTargetSize: BABYLON.Vector2;
  72359. private _bumpTexture;
  72360. bumpTexture: BABYLON.BaseTexture;
  72361. diffuseColor: BABYLON.Color3;
  72362. specularColor: BABYLON.Color3;
  72363. specularPower: number;
  72364. private _disableLighting;
  72365. disableLighting: boolean;
  72366. private _maxSimultaneousLights;
  72367. maxSimultaneousLights: number;
  72368. /**
  72369. * @param {number}: Represents the wind force
  72370. */
  72371. windForce: number;
  72372. /**
  72373. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  72374. */
  72375. windDirection: BABYLON.Vector2;
  72376. /**
  72377. * @param {number}: Wave height, represents the height of the waves
  72378. */
  72379. waveHeight: number;
  72380. /**
  72381. * @param {number}: Bump height, represents the bump height related to the bump map
  72382. */
  72383. bumpHeight: number;
  72384. /**
  72385. * @param {boolean}: Add a smaller moving bump to less steady waves.
  72386. */
  72387. private _bumpSuperimpose;
  72388. bumpSuperimpose: boolean;
  72389. /**
  72390. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  72391. */
  72392. private _fresnelSeparate;
  72393. fresnelSeparate: boolean;
  72394. /**
  72395. * @param {boolean}: bump Waves modify the reflection.
  72396. */
  72397. private _bumpAffectsReflection;
  72398. bumpAffectsReflection: boolean;
  72399. /**
  72400. * @param {number}: The water color blended with the refraction (near)
  72401. */
  72402. waterColor: BABYLON.Color3;
  72403. /**
  72404. * @param {number}: The blend factor related to the water color
  72405. */
  72406. colorBlendFactor: number;
  72407. /**
  72408. * @param {number}: The water color blended with the reflection (far)
  72409. */
  72410. waterColor2: BABYLON.Color3;
  72411. /**
  72412. * @param {number}: The blend factor related to the water color (reflection, far)
  72413. */
  72414. colorBlendFactor2: number;
  72415. /**
  72416. * @param {number}: Represents the maximum length of a wave
  72417. */
  72418. waveLength: number;
  72419. /**
  72420. * @param {number}: Defines the waves speed
  72421. */
  72422. waveSpeed: number;
  72423. /**
  72424. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  72425. * will avoid calculating useless pixels in the pixel shader of the water material.
  72426. */
  72427. disableClipPlane: boolean;
  72428. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  72429. private _mesh;
  72430. private _refractionRTT;
  72431. private _reflectionRTT;
  72432. private _reflectionTransform;
  72433. private _lastTime;
  72434. private _lastDeltaTime;
  72435. private _renderId;
  72436. private _useLogarithmicDepth;
  72437. private _waitingRenderList;
  72438. private _imageProcessingConfiguration;
  72439. private _imageProcessingObserver;
  72440. /**
  72441. * Gets a boolean indicating that current material needs to register RTT
  72442. */
  72443. readonly hasRenderTargetTextures: boolean;
  72444. /**
  72445. * Constructor
  72446. */
  72447. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  72448. useLogarithmicDepth: boolean;
  72449. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72450. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72451. addToRenderList(node: any): void;
  72452. enableRenderTargets(enable: boolean): void;
  72453. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  72454. readonly renderTargetsEnabled: boolean;
  72455. needAlphaBlending(): boolean;
  72456. needAlphaTesting(): boolean;
  72457. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72458. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72459. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72460. private _createRenderTargets;
  72461. getAnimatables(): BABYLON.IAnimatable[];
  72462. getActiveTextures(): BABYLON.BaseTexture[];
  72463. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72464. dispose(forceDisposeEffect?: boolean): void;
  72465. clone(name: string): WaterMaterial;
  72466. serialize(): any;
  72467. getClassName(): string;
  72468. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  72469. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  72470. }
  72471. }
  72472. declare module BABYLON {
  72473. /** @hidden */
  72474. export var asciiartPixelShader: {
  72475. name: string;
  72476. shader: string;
  72477. };
  72478. }
  72479. declare module BABYLON {
  72480. /**
  72481. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  72482. *
  72483. * It basically takes care rendering the font front the given font size to a texture.
  72484. * This is used later on in the postprocess.
  72485. */
  72486. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  72487. private _font;
  72488. private _text;
  72489. private _charSize;
  72490. /**
  72491. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72492. */
  72493. readonly charSize: number;
  72494. /**
  72495. * Create a new instance of the Ascii Art FontTexture class
  72496. * @param name the name of the texture
  72497. * @param font the font to use, use the W3C CSS notation
  72498. * @param text the caracter set to use in the rendering.
  72499. * @param scene the scene that owns the texture
  72500. */
  72501. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72502. /**
  72503. * Gets the max char width of a font.
  72504. * @param font the font to use, use the W3C CSS notation
  72505. * @return the max char width
  72506. */
  72507. private getFontWidth;
  72508. /**
  72509. * Gets the max char height of a font.
  72510. * @param font the font to use, use the W3C CSS notation
  72511. * @return the max char height
  72512. */
  72513. private getFontHeight;
  72514. /**
  72515. * Clones the current AsciiArtTexture.
  72516. * @return the clone of the texture.
  72517. */
  72518. clone(): AsciiArtFontTexture;
  72519. /**
  72520. * Parses a json object representing the texture and returns an instance of it.
  72521. * @param source the source JSON representation
  72522. * @param scene the scene to create the texture for
  72523. * @return the parsed texture
  72524. */
  72525. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  72526. }
  72527. /**
  72528. * Option available in the Ascii Art Post Process.
  72529. */
  72530. export interface IAsciiArtPostProcessOptions {
  72531. /**
  72532. * The font to use following the w3c font definition.
  72533. */
  72534. font?: string;
  72535. /**
  72536. * The character set to use in the postprocess.
  72537. */
  72538. characterSet?: string;
  72539. /**
  72540. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72541. * This number is defined between 0 and 1;
  72542. */
  72543. mixToTile?: number;
  72544. /**
  72545. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72546. * This number is defined between 0 and 1;
  72547. */
  72548. mixToNormal?: number;
  72549. }
  72550. /**
  72551. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  72552. *
  72553. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72554. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  72555. */
  72556. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  72557. /**
  72558. * The font texture used to render the char in the post process.
  72559. */
  72560. private _asciiArtFontTexture;
  72561. /**
  72562. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72563. * This number is defined between 0 and 1;
  72564. */
  72565. mixToTile: number;
  72566. /**
  72567. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72568. * This number is defined between 0 and 1;
  72569. */
  72570. mixToNormal: number;
  72571. /**
  72572. * Instantiates a new Ascii Art Post Process.
  72573. * @param name the name to give to the postprocess
  72574. * @camera the camera to apply the post process to.
  72575. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  72576. */
  72577. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  72578. }
  72579. }
  72580. declare module BABYLON {
  72581. /** @hidden */
  72582. export var digitalrainPixelShader: {
  72583. name: string;
  72584. shader: string;
  72585. };
  72586. }
  72587. declare module BABYLON {
  72588. /**
  72589. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  72590. *
  72591. * It basically takes care rendering the font front the given font size to a texture.
  72592. * This is used later on in the postprocess.
  72593. */
  72594. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  72595. private _font;
  72596. private _text;
  72597. private _charSize;
  72598. /**
  72599. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72600. */
  72601. readonly charSize: number;
  72602. /**
  72603. * Create a new instance of the Digital Rain FontTexture class
  72604. * @param name the name of the texture
  72605. * @param font the font to use, use the W3C CSS notation
  72606. * @param text the caracter set to use in the rendering.
  72607. * @param scene the scene that owns the texture
  72608. */
  72609. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72610. /**
  72611. * Gets the max char width of a font.
  72612. * @param font the font to use, use the W3C CSS notation
  72613. * @return the max char width
  72614. */
  72615. private getFontWidth;
  72616. /**
  72617. * Gets the max char height of a font.
  72618. * @param font the font to use, use the W3C CSS notation
  72619. * @return the max char height
  72620. */
  72621. private getFontHeight;
  72622. /**
  72623. * Clones the current DigitalRainFontTexture.
  72624. * @return the clone of the texture.
  72625. */
  72626. clone(): DigitalRainFontTexture;
  72627. /**
  72628. * Parses a json object representing the texture and returns an instance of it.
  72629. * @param source the source JSON representation
  72630. * @param scene the scene to create the texture for
  72631. * @return the parsed texture
  72632. */
  72633. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  72634. }
  72635. /**
  72636. * Option available in the Digital Rain Post Process.
  72637. */
  72638. export interface IDigitalRainPostProcessOptions {
  72639. /**
  72640. * The font to use following the w3c font definition.
  72641. */
  72642. font?: string;
  72643. /**
  72644. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72645. * This number is defined between 0 and 1;
  72646. */
  72647. mixToTile?: number;
  72648. /**
  72649. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72650. * This number is defined between 0 and 1;
  72651. */
  72652. mixToNormal?: number;
  72653. }
  72654. /**
  72655. * DigitalRainPostProcess helps rendering everithing in digital rain.
  72656. *
  72657. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72658. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  72659. */
  72660. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  72661. /**
  72662. * The font texture used to render the char in the post process.
  72663. */
  72664. private _digitalRainFontTexture;
  72665. /**
  72666. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72667. * This number is defined between 0 and 1;
  72668. */
  72669. mixToTile: number;
  72670. /**
  72671. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72672. * This number is defined between 0 and 1;
  72673. */
  72674. mixToNormal: number;
  72675. /**
  72676. * Instantiates a new Digital Rain Post Process.
  72677. * @param name the name to give to the postprocess
  72678. * @camera the camera to apply the post process to.
  72679. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  72680. */
  72681. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  72682. }
  72683. }
  72684. declare module BABYLON {
  72685. /** @hidden */
  72686. export var oceanPostProcessPixelShader: {
  72687. name: string;
  72688. shader: string;
  72689. };
  72690. }
  72691. declare module BABYLON {
  72692. /**
  72693. * Option available in the Ocean Post Process.
  72694. */
  72695. export interface IOceanPostProcessOptions {
  72696. /**
  72697. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72698. */
  72699. reflectionSize?: number | {
  72700. width: number;
  72701. height: number;
  72702. } | {
  72703. ratio: number;
  72704. };
  72705. /**
  72706. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72707. */
  72708. refractionSize?: number | {
  72709. width: number;
  72710. height: number;
  72711. } | {
  72712. ratio: number;
  72713. };
  72714. }
  72715. /**
  72716. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  72717. *
  72718. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72719. * Example usage:
  72720. * var pp = new OceanPostProcess("myOcean", camera);
  72721. * pp.reflectionEnabled = true;
  72722. * pp.refractionEnabled = true;
  72723. */
  72724. export class OceanPostProcess extends BABYLON.PostProcess {
  72725. /**
  72726. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  72727. */
  72728. /**
  72729. * Sets weither or not the real-time reflection is enabled on the ocean.
  72730. * Is set to true, the reflection mirror texture will be used as reflection texture.
  72731. */
  72732. reflectionEnabled: boolean;
  72733. /**
  72734. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  72735. */
  72736. /**
  72737. * Sets weither or not the real-time refraction is enabled on the ocean.
  72738. * Is set to true, the refraction render target texture will be used as refraction texture.
  72739. */
  72740. refractionEnabled: boolean;
  72741. /**
  72742. * Gets wether or not the post-processes is supported by the running hardware.
  72743. * This requires draw buffer supports.
  72744. */
  72745. readonly isSupported: boolean;
  72746. /**
  72747. * This is the reflection mirror texture used to display reflections on the ocean.
  72748. * By default, render list is empty.
  72749. */
  72750. reflectionTexture: BABYLON.MirrorTexture;
  72751. /**
  72752. * This is the refraction render target texture used to display refraction on the ocean.
  72753. * By default, render list is empty.
  72754. */
  72755. refractionTexture: BABYLON.RenderTargetTexture;
  72756. private _time;
  72757. private _cameraRotation;
  72758. private _cameraViewMatrix;
  72759. private _reflectionEnabled;
  72760. private _refractionEnabled;
  72761. private _geometryRenderer;
  72762. /**
  72763. * Instantiates a new Ocean Post Process.
  72764. * @param name the name to give to the postprocess.
  72765. * @camera the camera to apply the post process to.
  72766. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  72767. */
  72768. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  72769. /**
  72770. * Returns the appropriate defines according to the current configuration.
  72771. */
  72772. private _getDefines;
  72773. /**
  72774. * Computes the current camera rotation as the shader requires a camera rotation.
  72775. */
  72776. private _computeCameraRotation;
  72777. }
  72778. }
  72779. declare module BABYLON {
  72780. /** @hidden */
  72781. export var brickProceduralTexturePixelShader: {
  72782. name: string;
  72783. shader: string;
  72784. };
  72785. }
  72786. declare module BABYLON {
  72787. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  72788. private _numberOfBricksHeight;
  72789. private _numberOfBricksWidth;
  72790. private _jointColor;
  72791. private _brickColor;
  72792. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72793. updateShaderUniforms(): void;
  72794. numberOfBricksHeight: number;
  72795. numberOfBricksWidth: number;
  72796. jointColor: BABYLON.Color3;
  72797. brickColor: BABYLON.Color3;
  72798. /**
  72799. * Serializes this brick procedural texture
  72800. * @returns a serialized brick procedural texture object
  72801. */
  72802. serialize(): any;
  72803. /**
  72804. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  72805. * @param parsedTexture defines parsed texture data
  72806. * @param scene defines the current scene
  72807. * @param rootUrl defines the root URL containing brick procedural texture information
  72808. * @returns a parsed Brick Procedural BABYLON.Texture
  72809. */
  72810. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  72811. }
  72812. }
  72813. declare module BABYLON {
  72814. /** @hidden */
  72815. export var cloudProceduralTexturePixelShader: {
  72816. name: string;
  72817. shader: string;
  72818. };
  72819. }
  72820. declare module BABYLON {
  72821. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  72822. private _skyColor;
  72823. private _cloudColor;
  72824. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72825. updateShaderUniforms(): void;
  72826. skyColor: BABYLON.Color4;
  72827. cloudColor: BABYLON.Color4;
  72828. /**
  72829. * Serializes this cloud procedural texture
  72830. * @returns a serialized cloud procedural texture object
  72831. */
  72832. serialize(): any;
  72833. /**
  72834. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  72835. * @param parsedTexture defines parsed texture data
  72836. * @param scene defines the current scene
  72837. * @param rootUrl defines the root URL containing cloud procedural texture information
  72838. * @returns a parsed Cloud Procedural BABYLON.Texture
  72839. */
  72840. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  72841. }
  72842. }
  72843. declare module BABYLON {
  72844. /** @hidden */
  72845. export var fireProceduralTexturePixelShader: {
  72846. name: string;
  72847. shader: string;
  72848. };
  72849. }
  72850. declare module BABYLON {
  72851. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  72852. private _time;
  72853. private _speed;
  72854. private _autoGenerateTime;
  72855. private _fireColors;
  72856. private _alphaThreshold;
  72857. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72858. updateShaderUniforms(): void;
  72859. render(useCameraPostProcess?: boolean): void;
  72860. static readonly PurpleFireColors: BABYLON.Color3[];
  72861. static readonly GreenFireColors: BABYLON.Color3[];
  72862. static readonly RedFireColors: BABYLON.Color3[];
  72863. static readonly BlueFireColors: BABYLON.Color3[];
  72864. autoGenerateTime: boolean;
  72865. fireColors: BABYLON.Color3[];
  72866. time: number;
  72867. speed: BABYLON.Vector2;
  72868. alphaThreshold: number;
  72869. /**
  72870. * Serializes this fire procedural texture
  72871. * @returns a serialized fire procedural texture object
  72872. */
  72873. serialize(): any;
  72874. /**
  72875. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  72876. * @param parsedTexture defines parsed texture data
  72877. * @param scene defines the current scene
  72878. * @param rootUrl defines the root URL containing fire procedural texture information
  72879. * @returns a parsed Fire Procedural BABYLON.Texture
  72880. */
  72881. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  72882. }
  72883. }
  72884. declare module BABYLON {
  72885. /** @hidden */
  72886. export var grassProceduralTexturePixelShader: {
  72887. name: string;
  72888. shader: string;
  72889. };
  72890. }
  72891. declare module BABYLON {
  72892. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  72893. private _grassColors;
  72894. private _groundColor;
  72895. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72896. updateShaderUniforms(): void;
  72897. grassColors: BABYLON.Color3[];
  72898. groundColor: BABYLON.Color3;
  72899. /**
  72900. * Serializes this grass procedural texture
  72901. * @returns a serialized grass procedural texture object
  72902. */
  72903. serialize(): any;
  72904. /**
  72905. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  72906. * @param parsedTexture defines parsed texture data
  72907. * @param scene defines the current scene
  72908. * @param rootUrl defines the root URL containing grass procedural texture information
  72909. * @returns a parsed Grass Procedural BABYLON.Texture
  72910. */
  72911. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  72912. }
  72913. }
  72914. declare module BABYLON {
  72915. /** @hidden */
  72916. export var marbleProceduralTexturePixelShader: {
  72917. name: string;
  72918. shader: string;
  72919. };
  72920. }
  72921. declare module BABYLON {
  72922. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  72923. private _numberOfTilesHeight;
  72924. private _numberOfTilesWidth;
  72925. private _amplitude;
  72926. private _jointColor;
  72927. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72928. updateShaderUniforms(): void;
  72929. numberOfTilesHeight: number;
  72930. amplitude: number;
  72931. numberOfTilesWidth: number;
  72932. jointColor: BABYLON.Color3;
  72933. /**
  72934. * Serializes this marble procedural texture
  72935. * @returns a serialized marble procedural texture object
  72936. */
  72937. serialize(): any;
  72938. /**
  72939. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  72940. * @param parsedTexture defines parsed texture data
  72941. * @param scene defines the current scene
  72942. * @param rootUrl defines the root URL containing marble procedural texture information
  72943. * @returns a parsed Marble Procedural BABYLON.Texture
  72944. */
  72945. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  72946. }
  72947. }
  72948. declare module BABYLON {
  72949. /** @hidden */
  72950. export var normalMapProceduralTexturePixelShader: {
  72951. name: string;
  72952. shader: string;
  72953. };
  72954. }
  72955. declare module BABYLON {
  72956. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  72957. private _baseTexture;
  72958. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72959. updateShaderUniforms(): void;
  72960. render(useCameraPostProcess?: boolean): void;
  72961. resize(size: any, generateMipMaps: any): void;
  72962. baseTexture: BABYLON.Texture;
  72963. /**
  72964. * Serializes this normal map procedural texture
  72965. * @returns a serialized normal map procedural texture object
  72966. */
  72967. serialize(): any;
  72968. /**
  72969. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  72970. * @param parsedTexture defines parsed texture data
  72971. * @param scene defines the current scene
  72972. * @param rootUrl defines the root URL containing normal map procedural texture information
  72973. * @returns a parsed Normal Map Procedural BABYLON.Texture
  72974. */
  72975. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  72976. }
  72977. }
  72978. declare module BABYLON {
  72979. /** @hidden */
  72980. export var perlinNoiseProceduralTexturePixelShader: {
  72981. name: string;
  72982. shader: string;
  72983. };
  72984. }
  72985. declare module BABYLON {
  72986. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  72987. time: number;
  72988. timeScale: number;
  72989. translationSpeed: number;
  72990. private _currentTranslation;
  72991. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72992. updateShaderUniforms(): void;
  72993. render(useCameraPostProcess?: boolean): void;
  72994. resize(size: any, generateMipMaps: any): void;
  72995. /**
  72996. * Serializes this perlin noise procedural texture
  72997. * @returns a serialized perlin noise procedural texture object
  72998. */
  72999. serialize(): any;
  73000. /**
  73001. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  73002. * @param parsedTexture defines parsed texture data
  73003. * @param scene defines the current scene
  73004. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  73005. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  73006. */
  73007. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  73008. }
  73009. }
  73010. declare module BABYLON {
  73011. /** @hidden */
  73012. export var roadProceduralTexturePixelShader: {
  73013. name: string;
  73014. shader: string;
  73015. };
  73016. }
  73017. declare module BABYLON {
  73018. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  73019. private _roadColor;
  73020. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73021. updateShaderUniforms(): void;
  73022. roadColor: BABYLON.Color3;
  73023. /**
  73024. * Serializes this road procedural texture
  73025. * @returns a serialized road procedural texture object
  73026. */
  73027. serialize(): any;
  73028. /**
  73029. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  73030. * @param parsedTexture defines parsed texture data
  73031. * @param scene defines the current scene
  73032. * @param rootUrl defines the root URL containing road procedural texture information
  73033. * @returns a parsed Road Procedural BABYLON.Texture
  73034. */
  73035. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  73036. }
  73037. }
  73038. declare module BABYLON {
  73039. /** @hidden */
  73040. export var starfieldProceduralTexturePixelShader: {
  73041. name: string;
  73042. shader: string;
  73043. };
  73044. }
  73045. declare module BABYLON {
  73046. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  73047. private _time;
  73048. private _alpha;
  73049. private _beta;
  73050. private _zoom;
  73051. private _formuparam;
  73052. private _stepsize;
  73053. private _tile;
  73054. private _brightness;
  73055. private _darkmatter;
  73056. private _distfading;
  73057. private _saturation;
  73058. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73059. updateShaderUniforms(): void;
  73060. time: number;
  73061. alpha: number;
  73062. beta: number;
  73063. formuparam: number;
  73064. stepsize: number;
  73065. zoom: number;
  73066. tile: number;
  73067. brightness: number;
  73068. darkmatter: number;
  73069. distfading: number;
  73070. saturation: number;
  73071. /**
  73072. * Serializes this starfield procedural texture
  73073. * @returns a serialized starfield procedural texture object
  73074. */
  73075. serialize(): any;
  73076. /**
  73077. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  73078. * @param parsedTexture defines parsed texture data
  73079. * @param scene defines the current scene
  73080. * @param rootUrl defines the root URL containing startfield procedural texture information
  73081. * @returns a parsed Starfield Procedural BABYLON.Texture
  73082. */
  73083. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  73084. }
  73085. }
  73086. declare module BABYLON {
  73087. /** @hidden */
  73088. export var woodProceduralTexturePixelShader: {
  73089. name: string;
  73090. shader: string;
  73091. };
  73092. }
  73093. declare module BABYLON {
  73094. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  73095. private _ampScale;
  73096. private _woodColor;
  73097. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73098. updateShaderUniforms(): void;
  73099. ampScale: number;
  73100. woodColor: BABYLON.Color3;
  73101. /**
  73102. * Serializes this wood procedural texture
  73103. * @returns a serialized wood procedural texture object
  73104. */
  73105. serialize(): any;
  73106. /**
  73107. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  73108. * @param parsedTexture defines parsed texture data
  73109. * @param scene defines the current scene
  73110. * @param rootUrl defines the root URL containing wood procedural texture information
  73111. * @returns a parsed Wood Procedural BABYLON.Texture
  73112. */
  73113. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  73114. }
  73115. }